即使此问题与this重复,也无法解决我的问题。 我的问题是当我通过邮件中的超链接启动应用程序时,我的应用程序再次打开作为新任务,即使应用程序已经在后台。我正在使用 机器人:launchMode = “标准”
如果我使用android:launchMode =“singleTask”,它解决了我的问题,但每当我从主屏幕启动应用程序时,即使应用程序处于后台,它也会从启动画面活动开始。请提出解决方案以解决上述两个问题。
我还了解了Google doc中的启动模式。但我的思想并没有那么多的知识值得观察。 提前谢谢。
答案 0 :(得分:0)
使用launchMode =" singleTask"
,这对我有用将此添加到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)) {
Log.w("LOG_TAG", "Main Activity is not the root. Finishing Main Activity instead of launching.");
finish();
return;
}
}
从here回答。
谢谢伙伴。