小编ahm*_*ady的帖子

我无法在 Android 模拟器中接收 Firebase Cloud Messaging FCM

我正在开发一个必须接收推送通知的应用程序,我尝试了一切使其工作,但它不起作用,这是我的代码

public class MyFirebaseInstanceService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        if (remoteMessage.getData().isEmpty()) {

            showNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
        }

        else
        {
            showNotification(remoteMessage.getData());

        }

    }

    private void showNotification(Map<String, String> data) {
        String title = data.get("title").toString();
        String body = data.get("body").toString();


        NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        String NOTIFICATION_CHANNEL_ID = "example.myapplication.service.test";

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
        {
            NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,"Notification",
                    NotificationManager.IMPORTANCE_DEFAULT);

            notificationChannel.setDescription("Team Tarang");
            notificationChannel.enableLights(true);
            notificationChannel.setLightColor(Color.BLUE);
            notificationChannel.enableLights(true);
            notificationManager.createNotificationChannel(notificationChannel);
        }

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,NOTIFICATION_CHANNEL_ID);

        notificationBuilder.setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setContentTitle(title)
                .setContentText(body)
                .setContentInfo("Info");

        notificationManager.notify(new Random().nextInt(),notificationBuilder.build());


    }

    private …
Run Code Online (Sandbox Code Playgroud)

java android firebase firebase-cloud-messaging

3
推荐指数
1
解决办法
3997
查看次数

导出应用程序时出现令人震惊的错误

我有一个很大的问题,我的Android应用程序在AVD模拟器上工作正常,但当我尝试将其导出为SDK包时出现许多unlogic错误我认为原因是应用程序中的一些东西"AndroidManifest.xml"

这是我的"AndroidManifest.xml"代码

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.googlecloudmessaging"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:name="com.example.googlecloudmessaging.permission.C2D_MESSAGE"
                android:protectionLevel="signature" ></permission>

    <uses-permission android:name="com.example.googlecloudmessaging.permission.C2D_MESSAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


    <receiver
        android:name=".GcmReceiver"
        android:permission="com.google.android.c2dm.permission.SEND"
        >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.example.googlecloudmessaging"/>
        </intent-filter>
    </receiver>

    <service android:name=".GcmMessageHandler"></service>

    <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>
    </application>

</manifest>
Run Code Online (Sandbox Code Playgroud)

这是unlogic错误

 "app_name" is not translated in "af" (Afrikaans), …
Run Code Online (Sandbox Code Playgroud)

sdk android

-1
推荐指数
1
解决办法
3108
查看次数

如何使用循环更新 SQL Server 数据库中的所有表

我在数据库中的所有表中有一个公共列,我需要通过所有表中的循环来更新此列的值

我尝试使用这段代码但没有发生任何事情

DECLARE TBL_CURSOR CURSOR
FOR ( SELECT Name FROM Sysobjects WHERE Type='U' )

DECLARE @SQL NVARCHAR(MAX);
SET @SQL = '';

DECLARE @TblName NVARCHAR(MAX);

OPEN TBL_CURSOR

FETCH NEXT FROM TBL_CURSOR INTO @TblName

BEGIN

   SET @SQL = ' If not exists (select column_name from INFORMATION_SCHEMA.columns where  table_name = '+ @TblName +' and column_name = "CommonColumn") update ' + @TblName + ' set CommonColumn= 1 ';
  FETCH NEXT FROM TBL_CURSOR INTO @TblName
END

CLOSE TBL_CURSOR
DEALLOCATE TBL_CURSOR

EXEC (@SQL);
Run Code Online (Sandbox Code Playgroud)

有人有更好的想法或修复此代码吗?

sql sql-server sql-server-2005

-1
推荐指数
1
解决办法
7645
查看次数