Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.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 单击“通知时关闭旧意图”_Android_Android Intent_Notifications - Fatal编程技术网

Android 单击“通知时关闭旧意图”

Android 单击“通知时关闭旧意图”,android,android-intent,notifications,Android,Android Intent,Notifications,我无法从本地通知中获取新的意图并关闭旧的意图 Intent notificationIntent = new Intent(this, QueueListViewActivity.class); notificationIntent.putExtra("key", "myqueue"); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 通常,我使用唯一的“键”启动意

我无法从本地通知中获取新的意图并关闭旧的意图

Intent notificationIntent = new Intent(this, QueueListViewActivity.class);
notificationIntent.putExtra("key", "myqueue");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
通常,我使用唯一的“键”启动意图

当我使用通知意图时,它不会关闭旧的通知意图

Intent notificationIntent = new Intent(this, QueueListViewActivity.class);
notificationIntent.putExtra("key", "myqueue");
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

如果存在旧的意图,如何使通知关闭?

如何“关闭”意图?我尝试在清单上使用android:launchMode=“singleTop”,但它只是关闭旧的意图,而不是启动新的意图。您应该在清单中将活动设置为
android:launchMode=singleTask
。这将防止重复活动。请阅读上面的评论。。无论如何,是否有关闭旧的意图并开始新的意图?使用不同的“putExtra(“key”,“myqueue”)”>?我认为您将
意图
活动
混淆了。