0

我正在尝试获取一个以对话框为主题的活动,以在从通知打开时清除父视图。

public class addNotification extends BroadcastReceiver {
NotificationManager nm;
final int x = -100;
public void onReceive(Context context, Intent intent) {
        Intent openAdd = new Intent(context,AddDialog.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent createShortcut = PendingIntent.getActivity(context, x, openAdd, 0);
        nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder buildNotification = new Notification.Builder(context)
                .setSmallIcon(R.drawable.add_task)
                .setContentTitle("Quick Entry")
                .setContentText("Click here enter data")
                .setTicker("quick entry service started.")
                .setAutoCancel(false)
                .setContentIntent(createShortcut);
    Notification notification = buildNotification.build();
    notification.flags |= Notification.FLAG_ONGOING_EVENT;
        buildNotification.setDefaults(Notification.FLAG_ONGOING_EVENT);
        nm.notify(x, notification);
    }
}

现在,当活动在最近菜单中时,单击通知将跳转到包含活动的应用程序。如果从最近删除应用程序,该应用程序将执行所需的功能,即在当前用于快速数据输入的任何应用程序上生成覆盖。

如何清除应用程序的堆栈,以便只显示具有意图的活动,而不显示任何父活动?

4

1 回答 1

0

尝试使用singleInstance 启动模式

与“singleTask”相同,只是系统不会在持有该实例的任务中启动任何其他活动。活动始终是其任务的唯一且唯一的成员。

于 2013-07-10T23:22:01.337 回答