活动在强制关闭时重新启动 [英] Activity restarts on Force Close

查看:21
本文介绍了活动在强制关闭时重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有单个根 Activity 的应用程序.我最近注意到我的 Activity 上的任何强制关闭都会导致它重新启动,我不知道为什么会发生这种情况.如果我强制未捕获的异常或使用长按强制关闭"选项,它们都会产生相同的结果.

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 have no idea why this might happen. If I force an uncaught exception or use the 'long back press to force close' option, they both result in the same.

我唯一的猜测是与保留对 Activity 某些部分的引用有关的某种形式的怪癖,只是我在应用程序级别没有任何 WeakReference 条目之外的任何条目.

My only guess would have been some form of quirk relating to retained references to some part of the Activity, only I don't have any outside of some WeakReference entries at the Application level.

相关的logcat条目:

Relevant logcat entries:

05-25 08:25:49.137: INFO/ActivityManager(18449): Displayed uk.co.randomicon.rstb/.TreeBuilderActivity: +8s82ms
05-25 08:25:54.222: DEBUG/dalvikvm(18546): GC_EXPLICIT freed 12K, 57% free 3640K/8327K, external 8323K/10136K, paused 72ms
05-25 08:25:55.373: WARN/InputManagerService(18449): Got RemoteException sending setActive(false) notification to pid 19122 uid 10069
05-25 08:25:59.217: DEBUG/dalvikvm(18646): GC_EXPLICIT freed 128K, 48% free 2980K/5703K, external 0K/0K, paused 67ms
05-25 08:26:00.238: DEBUG/dalvikvm(18991): GC_CONCURRENT freed 343K, 51% free 2794K/5639K, external 303K/532K, paused 3ms+3ms
05-25 08:26:02.950: INFO/Process(18449): Sending signal. PID: 19554 SIG: 9
05-25 08:26:02.980: INFO/ActivityManager(18449): Process uk.co.randomicon.rstb (pid 19554) has died.
05-25 08:26:02.990: ERROR/InputDispatcher(18449): channel '40a16ec8 uk.co.randomicon.rstb/uk.co.randomicon.rstb.TreeBuilderActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
05-25 08:26:02.990: ERROR/InputDispatcher(18449): channel '40a16ec8 uk.co.randomicon.rstb/uk.co.randomicon.rstb.TreeBuilderActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
05-25 08:26:02.990: INFO/WindowManager(18449): WINDOW DIED Window{40a16ec8 uk.co.randomicon.rstb/uk.co.randomicon.rstb.TreeBuilderActivity paused=false}
05-25 08:26:03.010: WARN/WindowManager(18449): Failed looking up window
05-25 08:26:03.010: WARN/WindowManager(18449): java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@40c774e0 does not exist
05-25 08:26:03.010: WARN/WindowManager(18449):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:8177)
05-25 08:26:03.010: WARN/WindowManager(18449):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:8168)
05-25 08:26:03.010: WARN/WindowManager(18449):     at com.android.server.WindowManagerService$WindowState$DeathRecipient.binderDied(WindowManagerService.java:7026)
05-25 08:26:03.010: WARN/WindowManager(18449):     at android.os.BinderProxy.sendDeathNotice(Binder.java:385)
05-25 08:26:03.010: WARN/WindowManager(18449):     at dalvik.system.NativeStart.run(Native Method)
05-25 08:26:03.010: INFO/WindowManager(18449): WIN DEATH: null
05-25 08:26:03.020: INFO/ActivityManager(18449): Start proc uk.co.randomicon.rstb for activity uk.co.randomicon.rstb/.TreeBuilderActivity: pid=19565 uid=10069 gids={1015}

我们将不胜感激地收到任何想法甚至开始戳!

Any ideas where to even begin poking would be gratefully received!

这是由于我在 Manifest 中设置 android:stateNotNeeded="true" 造成的.虽然我不需要状态,但这导致 Android 决定最好重新启动我的应用,假设用户希望这样做.

This was caused by me setting android:stateNotNeeded="true" in my Manifest. While I don't need the state, this caused Android to decide it was best to relaunch my app on the assumption the user would want that.

推荐答案

这里是一些有用的信息:

就活动何时重新启动而言——如果运行该活动的进程前台活动消失,系统将丢弃该活动,如果它没有有效的保存状态(通常意味着它已暂停并且已经给了系统 onSaveInstanceState 之前的结果暂停).一旦它决定是否丢弃该活动,它将恢复现在位于堆栈顶部的任何活动.如果这是你的一项活动——要么是因为你有另一项活动崩溃了,或者崩溃的那个不知何故是稳定的暂停状态-- 然后它将再次启动您的流程以显示该顶级活动.

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.

这篇关于活动在强制关闭时重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆