我的应用程序有一个相当奇怪的行为。我在 BOOT_COMPLETE 之后启动我的应用程序,因此在我启动设备后它是可见的。 GUI 响应迅速,一切正常,直到我调用 finish(),按下按钮时,什么都没有发生。 GUI 仍然响应并且没有产生 ANR 或可疑的 logcat 消息,所以我没有提示。
到目前为止我试过:
- 附加调试器并跟踪调用,但我找不到任何东西
- 我检查了activity的运行实例(用eclipse内存分析器),Memory中只有一个
- 我暂停了启动,几秒钟后 finish() 工作正常(这是我目前的解决方法)
不幸的是,没有有用的代码可以发布来演示这个问题,因为在以后的任何时间点启动 Activity 时一切正常。
有什么办法解决这个问题吗?
我在三星设备上运行 Android 2.1,我在 HTC Desire 上的 Android 2.2 上测试了它,但这个错误没有发生在 Nexus 4 上,也没有发生在模拟器上,也许它是特定于设备/版本的。
biên tập这是 Activity list 条目
<>
android:name=".activity.MyActivity"
android:enabled="false"
android:excludeFromRecents="true"
android:exported="false"
android:immersive="true"
android:launchMode="singleInstance"
>
为什么您的 Activity 被禁用?来自 Android 文档:
android:enabled- Whether or not the activity can be instantiated by the system — "true" if it can be, and "false" if not. The default value is "true".
这可能会使系统感到困惑,当您调用 finish 时它只看到 Actvity 被禁用,请尝试将其设置为 true。
Tôi là một lập trình viên xuất sắc, rất giỏi!