Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

Android 4.4.2 - java.lang.RuntimeException: Performing stop of activity that is not resumed

I'm getting this exception on a 4.4.2 device. Not reproducible on Android 4.3 device or lower.

Setup is I have a home activity (subclass of support ActionBarActivity). The home activity checks a boolean flag, and if true, launches a splash screen activity (yes, ideally the splash comes before the home activity, but let's assume I can't change it to work that way for now).

The splash screen is launched with startActivityForResult, it downloads some config options from the server, then finishes and returns the result back to the home activity.

Weird thing is this works fine on 4.3 and below, but on 4.4 devices, I get the above exception (full stack trace):

02-21 13:36:16.733  24409-24409/test.player E/ActivityThread﹕ Performing stop of activity that is not resumed: {test.player/test.ui.actvities.HomeActivity}
    java.lang.RuntimeException: Performing stop of activity that is not resumed: {test.player/test.ui.actvities.HomeActivity}
            at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3147)
            at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3234)
            at android.app.ActivityThread.access$1100(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5017)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)

Based on the above, it looks like onStop (because I launch the splash activity on onCreate) is called before onResume for the Home Activity.

Why is this now causing problems in 4.4.x?

question from:https://stackoverflow.com/questions/21947675/android-4-4-2-java-lang-runtimeexception-performing-stop-of-activity-that-is

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That doesn't seem right to me. The splash activity would now be the top activity in the stack, so the HomeActivity onStop lifecycle method would get called eventually. Coincidentally, I moved the startActivity call for the splash activity from onCreate to onResume in the HomeActivity, and the error goes away.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...