Android的活动单 [英] Android Activity singleton
问题描述
我有一个名为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
这篇关于Android的活动单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!