经过Home键preSS重新启动应用程序显示初始活性不电流 [英] After Home button press re-launching app shows initial activity not current

查看:176
本文介绍了经过Home键preSS重新启动应用程序显示初始活性不电流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有具有初始活性(甲 - 也是在发射器中指定的一个)的应用从它允许用户启动另一个活性(B)中。我现在的储蓄活动B的状态(的onSaveInstanceState(),并恢复它的onCreate())。

I have an application that has an initial activity (A - also the one specified in the launcher) from which it allows the user to launch another activity (B). I am saving the state of Activity B (onSaveInstanceState() and restoring it in onCreate()).

在某些手机上(N1和Motrola里程碑的,但现在不是银河S)推出B如果用户presses home键后(即应用程序被切换到后台),然后立即重新启动应用程序,他们显示活性的再次(没有B)。但是,如果他们启动它从'最近'的应用程序(Home键长preSS),他们被带到b活动。

On some phones (N1 and Motrola Milestone as of now but not the Galaxy S) after launching B if the user presses the home button (i.e. app goes to background) and then immediately re-launches the app, they are shown activity A again (not B). But if they launch it from the 'Recent' apps (Home button long press) they are taken to the activity B.

据我了解了Android文档中,除非该任务已被杀死(似乎不喜欢这里没有别的,除了重新启动从应用程序屏幕上做了活动的情况下),我们应该看到b活动恢复在启动(因为这是在堆栈的顶部)。所以,我只是似乎无法弄清楚到底是什么错在这里。

From what I understand of the Android docs, unless the task has been killed (doesnt seem like the case here as nothing else is done except re-launch the activity from the app screen) we should see activity B restored on launch (as that is on top of the stack). So I just can't seem to figure out what the heck is wrong here.

BTW应用使用过程中的方向变化工作正常(一切保存并恢复正常)。这个奇怪的问题已被窃听我有一段时间了,并通过试错我发现,当我禁用取向的活动,然后尝试重新启动了B至表现符合市场预期。

BTW orientation changes during app usage works fine (everything saves and restores fine). This weird problem has been bugging me for some time now and by trial and error I discovered that when I disabled orientation for that activity and then trying the re-launching got B to show as expected.

那么有没有其他人遇到这样的事情,如果是这样怎么可以这样解决?

So has anyone else faced something like this and if so how can this be resolved?

我期待到保存正在运行活动的共享preferences(如上文<一个href="http://stackoverflow.com/questions/6364418/android-show-last-viewed-activity-when-$p$pss-home-button-app-shortcut">in这篇文章),他们从恢复它的活性的,但想知道如果我失去了一些东西。如果没有乙上重新启动恢复是默认行为?

I am looking into saving the running activity in SharedPreferences (as mentioned in this post) and they restoring it from that in activity A, however would like to know if I am missing something here. Shouldn't having B restored on re-launch be the default behavior?

推荐答案

尝试添加到您的活动清单文件中:

Try adding this to your activity inside the manifest file:

android:launchMode="singleTask"

这在我的应用程序解决了这个问题....如果我正确理解你的问题。

This resolved the issue in my app .... if I understand your problem correctly.

这篇关于经过Home键preSS重新启动应用程序显示初始活性不电流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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