从启动启动器图标现有singleTask活动 [英] Launch existing singleTask Activity from launcher icon

查看:209
本文介绍了从启动启动器图标现有singleTask活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情景:


  • 活动A(MAIN和LAUNCHER在清单)上的启动器图标时,点击启动。

  • Activity A (MAIN and LAUNCHER in manifest) starts up when clicking on launcher icon.

在轮到启动活动B。

活动B然后启动我们的主要应用程序的活动C(MAIN和singleTask在清单)。

Activity B then launches our main app Activity C (MAIN and singleTask in manifest).

行为我需要:

在活动C已经被证明和home键是那么pressed,下一次启动程序图标pressed我想直接跳到活动C(而不是展示活动A(因而乙)再次)。

Once Activity C has been shown and the home key is then pressed, the next time the launcher icon is pressed I would like to skip straight to Activity C (and not show Activity A (and consequently B) again).

我一直在使用FLAG_ACTIVITY_CLEAR_TOP从A试过,但我仍然得到活动A,每当我打了启动屏幕上的图标。

I have tried using FLAG_ACTIVITY_CLEAR_TOP from A, but I still get Activity A whenever I hit icon on launch screen.

从发射我singletask活动的C外观实现?

Is appearance of my singletask Activity C from launcher achievable?

更新:从A FLAG_ACTIVITY_CLEAR_TOP使用,而不是调用完成(),从而创建活动B的启动器图标的preSS出现的情况。然而,也将使用选自B FLAG_ACTIVITY_CLEAR_TOP,而不是调用完成()不能解决的情况。现在我没有得到一个关于启动器图标preSS,但得到B.是什么给了!

Update: Use of FLAG_ACTIVITY_CLEAR_TOP from A and not calling finish() creates the situation whereby Activity B appears on press of launcher icon. However, also applying use of FLAG_ACTIVITY_CLEAR_TOP from B and not calling finish() does not resolve situation. now I don't get A on launcher icon press, but get B. What gives!

推荐答案

请参阅类似的情景<一个href=\"http://stackoverflow.com/questions/7238532/how-to-launch-activity-only-once-when-app-is-opened-for-first-time\">here.

在你的情况,我会建议使用类似的方法,在这里你将有一个共享preference将坚持重presenting您的应用程序是否具有previously已经启动的值。

In your case, I would recommend using a similar approach, where you would have a SharedPreference that would persist a value representing whether your app had previously been launched.

创建一个简单的活动,将包含你正在试图在这里做的逻辑。在该活动的(pre-A活动)onResume()方法,检查程序是否pviously跑了$ P $的的preference重新presenting的价值。

Create a simple Activity that will contain the logic for what you are trying to do here. In that activity's ("pre-A" Activity) onResume() method, check the value of the preference representing whether the app has ran previously.

如果它没有previously已经跑了,推出一个意向到活动A,它调用后续的B和C的活动;否则,发起意图活动℃。

If it has not previously been ran, launch an intent to Activity A, which calls the subsequent B and C activities; otherwise, launch an intent to Activity C.

好像pretty简单,只记得在你的清单来定义新的pre-A的活动!

Seems pretty straightforward, just remember to define the new "Pre-A" activity in your manifest!

这篇关于从启动启动器图标现有singleTask活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆