通知中的待处理意图无法运行Android

时间:2017-12-19 13:56:49

标签: android android-intent notifications android-pendingintent

我的未决意图无法正常工作。

问题是:点击通知时,它会重定向到Splash Activity,这是我的启动器应用程序活动,以下是我创建通知的代码。

  Intent intent = new Intent(this, QuickTasks.class).putExtra("NOTIFICATION", 1);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent resultIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri notificationSoundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle("Suvi")
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(notificationSoundURI)
            .setContentIntent(resultIntent);

    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0, mNotificationBuilder.build());     

请帮助我,在这方面我已经使用了很多可用的资源,但都没有工作。任何帮助都可能是值得的。感谢Advacne

1 个答案:

答案 0 :(得分:0)

通常,当您要从通知中开始活动时,有两种情况:

  1. 常规活动: 您正在启动一个活动,该活动是应用程序正常工作流程的一部分。
  2. 特殊活动: 如果该活动是从通知中启动的,则用户只会看到该活动。从某种意义上讲,活动通过提供难以在通知本身中显示的信息来扩展通知。

请参考以下链接。
Preserving Navigation when Starting an Activity
希望对您有帮助。