活动从模拟器中的主屏幕启动器恢复,但在 Android 设备上不恢复

发布于 2024-10-05 06:16:45 字数 567 浏览 0 评论 0原文

我的android应用程序有一个登录屏幕,它作为主要活动启动,其意图如下:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

没有其他异常(据我所知,关于其他活动等,没有对这些或任何东西设置额外的意图)。

使用模拟器,如果我登录并启动第二个活动,那么我按主页按钮,如果我从主屏幕快捷方式再次启动应用程序,任务将返回到第二个活动。这是所需的行为,因为我不希望用户必须一遍又一遍地登录。

对于 HTC Incredible 和 Droid X(仅限我可以访问的手机),如果我登录并启动第二个活动,然后按主页按钮,如果我从主屏幕快捷方式重新启动应用程序,它总是会启动登录活动,这不是想要的结果。我希望它在我停止的第二个活动处恢复。

有谁知道为什么这在模拟器上可以按预期工作,但在手机上却不能?非常感谢。

My android application has a login screen that is launched as the main activity with intents as follows:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Nothing else is out of the ordinary (that I am aware of, concerning the other activities, etc, no additional intents set on those or anything).

With the emulator, if I login and the second activity is launched, then I press the home button, if I launch the app again from a homescreen shortcut the task returns to the second activity. This is the desired behavior, as I don't want the user to have to login over and over again.

With both an HTC Incredible and a Droid X (only phones I have access to), if I login and the second activity launches, then press the home button, if I relaunch the app from a homescreen shortcut, it always launches the login activity, which is not the desired result. I want it to resume at the second activity where I left off.

Does anyone have any insight as to why this works as intended with the emulator but not on the phones? Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝天白云 2024-10-12 06:16:45

我想通了。我已经完全卸载了该应用程序,并从手机主屏幕上删除了快捷方式。然后它开始工作了。我的猜测是,这是主屏幕上的旧快捷方式,坚持不确定的意图或其他东西(因为我很确定我已经卸载了几次但无济于事)。一旦卸载/重新安装了所有内容并在主屏幕上创建了新的快捷方式,它就会按预期工作。希望这对其他人有帮助。

I figured it out. I had completely uninstalled the app and deleted the shortcut from my home screen on the phone. Then it started working. My guess is it was the old shortcut on the home screen holding on to iffy intents or something (because im pretty sure I've uninstalled it a few times to no avail). Once everything was uninstalled/reinstalled and a new shortcut was created on the home screen it is working as intended. Hope this helps someone else.

染墨丶若流云 2024-10-12 06:16:45

我的 HTC Desire 也有同样的情况。如果我通过使用 eclipse 或通过命令行从我的计算机安装 apk

亚行安装

一切正常。如果我从手机上的文件安装,我会得到您描述的行为。我想知道通过市场安装/更新会做什么,但害怕将其提供给用户。

与您的情况不同的是,卸载不会改变任何事情。有什么想法吗?

I have the same behaviour on my HTC Desire. If I install the apk from my computer either by using eclipse or by command line via

adb install

everything is fine. If I install from the file on the phone, I get the behaviour you describe. I wonder what install/update via the market does but am afraid to give it like that to the users.

The difference to your case is that uninstall does not change a thing. Any ideas?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文