Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么PendingEvent会打开应用程序的启动程序活动而不是特定活动?_Android_Android Pendingintent_Firebase Notifications - Fatal编程技术网

Android 为什么PendingEvent会打开应用程序的启动程序活动而不是特定活动?

Android 为什么PendingEvent会打开应用程序的启动程序活动而不是特定活动?,android,android-pendingintent,firebase-notifications,Android,Android Pendingintent,Firebase Notifications,我正在使用firebase发送通知。当用户单击通知时,它将打开ResultActivity。当应用程序位于前台时,它工作正常。但当应用程序位于后台时,它会打开HomeActivity(应用程序的启动程序活动),而不是ResultActivity。我不明白出了什么问题 public class MyFirebaseMessagingService extends FirebaseMessagingService { @Override public void onMessageR

我正在使用firebase发送通知。当用户单击通知时,它将打开ResultActivity。当应用程序位于前台时,它工作正常。但当应用程序位于后台时,它会打开HomeActivity(应用程序的启动程序活动),而不是ResultActivity。我不明白出了什么问题

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
        notificationBuilder.setContentTitle(getResources().getString(R.string.app_name));
        notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
        notificationBuilder.setAutoCancel(true);
        notificationBuilder.setSmallIcon(R.mipmap.ic_launcher);

        Intent intent = new Intent(getApplicationContext(), ResultActivity.class);

        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);

        notificationBuilder.setContentIntent(pendingIntent);
        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(0, notificationBuilder.build());
    }
}

这是测试点击动作映射的好方法。它需要一个类似FCM文档中指定的意图过滤器:

<intent-filter>
    <action android:name="OPEN_ACTIVITY_1" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

这是测试点击动作映射的好方法。它需要一个类似FCM文档中指定的意图过滤器:

<intent-filter>
    <action android:name="OPEN_ACTIVITY_1" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
看一看。它可能会对你有帮助。可能是复制品。请看一看。它可能对你有帮助。可能是