【发布时间】:2017-12-19 13:56:49
【问题描述】:
我的未决意图未按预期工作。
问题是:点击通知时,它会重定向到 Splash Activity,这是我的应用程序启动器 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());
请在这方面帮助我,我在这里使用了许多可用的资源,但没有一个有效。任何帮助都会很有意义。
【问题讨论】:
-
pending intent not working as to be expected to work是什么意思?解释行为以及例外行为 -
我想打开 QuickTasks.class 而不是打开启动画面
-
您确定
QuickTasks.class与启动活动无关,请在没有FLAG_ACTIVITY_CLEAR_TOP的情况下尝试,如果您仍然无法看到QuickTasks.class,那么您的代码中存在逻辑问题 -
您的 QuickTask 在开始时是否有特殊行为?谁可能会自动将您重定向到您的启动活动?
-
Splash Activity 是我的主要活动
标签: java android android-intent android-notifications android-pendingintent