Android的活动单Android

由网友(喂,我好饿)分享简介:我有一个名为MainActivity的活动。该活动将启动,有打开这个MainActivity一个PendingIntent的通知。I have an activity called MainActivity. This activity launches a notification that has a Pendi...

我有一个名为MainActivity的活动。该活动将启动,有打开这个MainActivity一个PendingIntent的通知。

I have an activity called MainActivity. This activity launches a notification that has a PendingIntent that opens this MainActivity.

因此​​,要关闭应用程序,我有两次单击后退按钮。我想建立活动为单身。我试图设置singleInstance或singleTask来体现,但是这并不工作。

So, to close the application, I have to click the back button twice. I would like to set up activity as singleton. I tried to set singleInstance or singleTask to manifest but this doesn't work.

推荐答案

singleInstance singleTask 不建议一般使用。

尝试:

 android:launchMode="singleTop"

有关详细信息,请参阅 launchMode部分

For more information please refer to launchMode section of the Activity element documentation.

在除previous引用您还应该阅读任务,回到堆栈

In addition to the previous reference you should also read tasks and back stack

阅读全文

相关推荐

最新文章