[android-developers] finish() at onStop causes ANR
We have two apks A and B. A starts B at onBackPressed. Doing as steps below can make ANR: 1)starts emulator and A; 2)put one finger on A and hold on it; 3)press ESC to do back key action and B is started; 4)release finger on B ANR will happens if we call finish() at onStop. And if we call finish() after startActivity and everything is all right. Below is log when ANR happens: 07-28 07:08:31.586 V/WindowManager( 52): Waiting for key dispatch: 5000 07-28 07:08:36.591 V/WindowManager( 52): Finished waiting @5174450 startTime=5169441 switchTime=0 target=Window{43e68d70 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.First paused=true} mLW=null mLB=null fin=true mCurrentFocus=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false} 07-28 07:08:36.591 W/WindowManager( 52): Key dispatching timed out sending to com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.First 07-28 07:08:36.614 W/WindowManager( 52): Dispatch state: {{KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false} @ 1280300903391 lw=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false} lb=android.os.binderpr...@43e6ed18 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false}}} 07-28 07:08:36.614 W/WindowManager( 52): Current state: {{null to Window{43e68d70 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.First paused=true} @ 1280300916617 lw=null lb=null fin=true gfw=true ed=true tts=0 wf=false fp=true mcf=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false}}} 07-28 07:08:36.632 I/ActivityManager( 52): ANR in process: com.neusoft.test.FakeFinishOnStop (last in com.neusoft.test.FakeFinishOnStop) Is this a bug? James -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] finish() at onStop causes ANR
On Thu, Jul 29, 2010 at 10:09 AM, James Wang jameswangc...@gmail.comwrote: A starts B at onBackPressed. ANR will happens if we call finish() at onStop. You're starting an activity in response to the button that's supposed to kill activities? And you're calling finish() in a life cycle method that's usually part of the destroy process anyway? Why? Why would do this? Is this a bug? Probably, but with your code, not Android. - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] finish() at onStop causes ANR
adb shell cat /data/anr/traces.txt That contains the stack crawls of the last ANR. On Thu, Jul 29, 2010 at 8:09 AM, James Wang jameswangc...@gmail.com wrote: We have two apks A and B. A starts B at onBackPressed. Doing as steps below can make ANR: 1)starts emulator and A; 2)put one finger on A and hold on it; 3)press ESC to do back key action and B is started; 4)release finger on B ANR will happens if we call finish() at onStop. And if we call finish() after startActivity and everything is all right. Below is log when ANR happens: 07-28 07:08:31.586 V/WindowManager( 52): Waiting for key dispatch: 5000 07-28 07:08:36.591 V/WindowManager( 52): Finished waiting @5174450 startTime=5169441 switchTime=0 target=Window{43e68d70 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.First paused=true} mLW=null mLB=null fin=true mCurrentFocus=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false} 07-28 07:08:36.591 W/WindowManager( 52): Key dispatching timed out sending to com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.First 07-28 07:08:36.614 W/WindowManager( 52): Dispatch state: {{KeyEvent{action=1 code=4 repeat=0 meta=0 scancode=158 mFlags=8} to Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false} @ 1280300903391 lw=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false} lb=android.os.binderpr...@43e6ed18 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false}}} 07-28 07:08:36.614 W/WindowManager( 52): Current state: {{null to Window{43e68d70 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.First paused=true} @ 1280300916617 lw=null lb=null fin=true gfw=true ed=true tts=0 wf=false fp=true mcf=Window{43ce5d28 com.neusoft.test.FakeFinishOnStop/ com.neusoft.test.FakeFinishOnStop.Second paused=false}}} 07-28 07:08:36.632 I/ActivityManager( 52): ANR in process: com.neusoft.test.FakeFinishOnStop (last in com.neusoft.test.FakeFinishOnStop) Is this a bug? James -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en