问题
When I use a configuration Activity for my app widget it crashes once I leave the activity with RESULT_OK set using my Nexus 5 with Android 4.4.2 and GEL Launcher (the default launcher). When I try the same with the Android SDK API Examples Widget, the same happens. Therefore I assume it is not the fault of my code. The same code works using my Nexus 4 with its default launcher and same Android version. The error log (using API Examples Widget) is as follows:
I/GEL ( 8852): handleIntent(Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.google.android.googlequicksearchbox/com.google.android.launcher.GEL })
D/AndroidRuntime( 8852): Shutting down VM
W/dalvikvm( 8852): threadid=1: thread exiting with uncaught exception (group=0x415b8ba8)
E/AndroidRuntime( 8852): FATAL EXCEPTION: main
E/AndroidRuntime( 8852): Process: com.google.android.googlequicksearchbox, PID: 8852
E/AndroidRuntime( 8852): java.lang.RuntimeException: Unable to resume activity {com.google.android.googlequicksearchbox/com.google.android.launcher.GEL}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=5, result=-1, data=Intent { (has extras) }} to activity {com.google.android.googlequicksearchbox/com.google.android.launcher.GEL}: java.lang.NullPointerException
E/AndroidRuntime( 8852): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2788)
E/AndroidRuntime( 8852): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2817)
E/AndroidRuntime( 8852): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
E/AndroidRuntime( 8852): at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime( 8852): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime( 8852): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 8852): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 8852): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 8852): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 8852): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 8852): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 8852): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 8852): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 8852): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=5, result=-1, data=Intent { (has extras) }} to activity {com.google.android.googlequicksearchbox/com.google.android.launcher.GEL}: java.lang.NullPointerException
E/AndroidRuntime( 8852): at android.app.ActivityThread.deliverResults(ActivityThread.java:3365)
E/AndroidRuntime( 8852): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2775)
E/AndroidRuntime( 8852): ... 12 more
E/AndroidRuntime( 8852): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 8852): at com.android.launcher3.Launcher.onActivityResult(Launcher.java:804)
E/AndroidRuntime( 8852): at com.google.android.launcher.GEL.onActivityResult(GEL.java:206)
E/AndroidRuntime( 8852): at android.app.Activity.dispatchActivityResult(Activity.java:5423)
E/AndroidRuntime( 8852): at android.app.ActivityThread.deliverResults(ActivityThread.java:3361)
E/AndroidRuntime( 8852): ... 13 more
W/ActivityManager( 792): Force finishing activity com.google.android.googlequicksearchbox/com.google.android.launcher.GEL
Looking at the source code of com.android.launcher3.Launcher.onActivityResult(Launcher.java:804) it seems that the variable mDragLayer is null. Does anyone has a workaround for this problem?
回答1:
I could not add widgets to my home screen and kept getting crashes in "googlequicksearchbox". Many hours of searching and tech support, I found this. Unchecking Settings-> Developer options-> Don't keep activities, fixed it.
回答2:
I have it! This happens if you check under Settings -> Developer options -> Don't keep activities. Seems like the drag layer is discarded then as well. Lesson learned.
来源:https://stackoverflow.com/questions/21041775/homescreen-app-widget-configuration-activity-crashes-under-gel-launcher