[英]After Home button pressed and pressed icon (on launcher) app restart
If install app from sd by default installer and Open button pressed will open app. 如果默认情况下从sd安装应用程序,并且按下“打开”按钮将打开应用程序。 After Home button pressed and click icon (on launcher) app will restart.
按下“主页”按钮并单击图标(在启动器上)后,应用程序将重新启动。 Need kill app from memory and start by icon on launcher for normal behaviour.
需要从内存中杀死应用程序,并通过启动器上的图标启动才能正常运行。
Steps: 脚步:
1. Create simple app 1.创建简单的应用
2. Load to sd 2.加载到SD
3. Install and Open from installer 3.从安装程序安装并打开
4. Change any behavior 4.改变任何行为
5. Pressed Home button 5.按下主页按钮
6. Pressed icon app on launcher 6.在启动器上按下图标应用程序
7. App restarting ! 7.应用重启!
If kill app from memory and run by icon on launcher will behavior is normal. 如果从内存中杀死应用程序并通过启动器上的图标运行,则行为正常。 How do it resolve it?
如何解决呢?
I solved this issue with the following code in the onCreate()
method: 我使用
onCreate()
方法中的以下代码解决了此问题:
if (!isTaskRoot()) {
final Intent intent = getIntent();
final String intentAction = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) &&
intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
finish();
}
}
Opposed to other proposed solutions, this does not require the declaration of "android.permission.GET_TASKS"
与其他建议的解决方案相反,这不需要声明
"android.permission.GET_TASKS"
Please check for the flag android:launchMode for activity in Android Manifest. 请检查Android清单中活动的标志android:launchMode。 Try deleting it and check.
尝试删除它并检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.