Activity restarts on Force Close

后端 未结 3 1881
小鲜肉
小鲜肉 2020-12-05 20:07

I have an Application with a single root Activity. I\'ve recently had it brought to my attention that any kind of Force Close on my Activity results in it restarting and I h

相关标签:
3条回答
  • 2020-12-05 20:51

    Here is some useful info:

    As far as when an activity is restarted -- if the process running the foreground activity goes away, the system will throw away that activity if it does not have a valid saved state for it (typically meaning it is paused and has given the system the result of onSaveInstanceState from before the pause). Once it has decided whether or not to throw away that activity, it will resume whatever activity is now at the top of the stack. If this is one of your activities -- either because you have another behind the one that crashed, or the one that crashed was somehow it the settled pause state -- then it will start your process again to show that top activity.

    0 讨论(0)
  • 2020-12-05 20:54

    if app has android:persistent="true" in manifest, it will restart when killed.

    0 讨论(0)
  • 2020-12-05 21:11

    This may be caused by calling a system API that is not available on your target device. I ran into a similar issue then trying to call ActivityManager.MemoryInfo.totalMem on a 4.0.x device. I didn't get any compile errors as I was targeting 4.2.2 and ActivityManager.MemoryInfo.totalMem was added in API16 (4.1)

    0 讨论(0)
提交回复
热议问题