应用程序什么时候重新启动?
有时我在 DDMS 中看到我的应用程序重新启动。正如我看到的,它的进程 ID 已更改。(我不确定,因为我没有为应用程序 oncreate 写入日志。)
当我安装 SDCard 以共享 USB 模式时,通常会发生这种行为。我想看看在我的应用程序中挂载后发生了什么。所以我调试我的应用程序,但不幸的是。当挂载到共享 USB 模式时,应用程序的进程 ID 发生了变化,并且调试被自动停止。
为什么?发生了什么?android处理应用程序重启的策略是什么?
还有一个问题。为什么有时一个 Activity 会发生错误,抛出异常对话框,然后重新启动它。有时 Android 平台会杀死该 Activity 并退出。
也许这对开发来说不是一个很有用的问题。但我真的很想知道答案。请朋友们帮助我。非常感谢。
Sometimes I see my app in DDMS restart.As I see it's process id changed.(I'm not sure that,because I don't write log for application oncreate.)
That behaviour ofen happened when I mount SDCard to share USB mode.I'd like to see what happend after mount in my application.So I debug my App,but unfortunately.When mount to share USB mode,application's process id changed and debug been auto stopped.
Why?What happened?What's the strategy for android handle application restart?
And there is another question.Why does sometimes an activity occur an error,thrown an exception dialog,and restart it.Sometimes the android platform just kill the activity and exit.
Maybe it's not a very useful question for develop.But I'm really missing,I want to know the answer.Please help me,friends.Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我曾经遇到过像你这样的类似情况,我所做的处理和检测如下:
1. 检查设备:有时设备故障确实会导致问题,坏的 USB 电缆确实会重新启动 Android/应用程序。
2.收集日志:应用程序重新启动后,只需从system/event/radio/dumpstate收集日志...记住应用程序开始重新启动的时间,然后检查日志文件以查找原因。
嗯,这就是我的经验,虽然不是在所有情况下但在大多数情况下都有效。
I used to get into similar cases like yours, what I did to handle and detect is like:
1. Check Device: sometimes devices mal-functioning really cause problems, a bad USB cable will really do restart Android/application.
2. Collect Log: after application restarts, just collect the log from system/event/radio/dumpstate... remember the time when app started to restart then check in log files to look for the causes.
Well, that's my experiences and it works, not in all situations but most of the time.