ANDROID 活动在重新启动时强制停止
我已经浏览了很多与此相关的其他线程,但还没有找到他们的解决方案。 当我第一次启动我的应用程序时,我注意到 onResume 在 onCreate 之后被调用。 (不知道为什么) 我的问题是当我尝试第二次运行该应用程序时。 onCreate 和 onResume 都不会被调用,它只是坐在那里。 另外,我在清单中设置了这些设置:
android:clearTaskOnLaunch="true"
android:screenOrientation="landscape"
android:noHistory="true"
如果我想多次运行我的应用程序,我必须进入设置 - >应用程序 - >应用程序名称 - >强制关闭
(我不有权查找可能导致卡住的任何循环或坏错误,因为我正在使用带有自己线程的库。)
有没有办法解决这个问题?
I've looked through a lot of other threads about this but haven't had any luck yet with their solutions.
When I launch my app for the first time, I noticed that onResume is being called after onCreate. (not sure why)
My problem is when I try to run the application for the second time. Neither onCreate nor onResume get called, it just sits there.
ALso, I have these setting set in my manifest:
android:clearTaskOnLaunch="true"
android:screenOrientation="landscape"
android:noHistory="true"
If I ever want to run my app more than once, I have to go into settings->applications->app-name->force-close
(I don't have access to look for any loops or bad bugs that might be causing the sticking because I'm using a library with it's own threads.)
Is there a way I can fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 onDestroy 方法中调用 Process.sendSignal(Process.myPid(), Process.SIGNAL_KILL);。这虽然不好,但却是解决这个问题的最佳方案。
Call
Process.sendSignal(Process.myPid(), Process.SIGNAL_KILL);
in your onDestroy method. This is not good but the best solution for this problem.这就是 android 管理活动的方式。如果您希望 Activity 经历整个生命周期,请显式调用其
finish()
方法。This is the way android manages the activities. If you want your activity go through whole life cycle, call explicitly its
finish()
method.