当我为我的应用小部件使用配置活动时,一旦我使用我的带有Android 4.4.2的Nexus 5和GEL Launcher(默认启动器)设置了RESULT_OK,它就会崩溃。当我尝试使用Android SDK API示例小部件时,同样的情况也会发生。因此我认为这不是我的代码的错。相同的代码使用我的Nexus 4及其默认启动器和相同的Android版本。错误日志(使用API Examples Widget)如下:
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
查看com.android.launcher3.Launcher.onActivityResult(Launcher.java:804)的源代码,似乎变量mDragLayer为null。有没有人有解决这个问题的方法?
答案 0 :(得分:2)
我无法将小部件添加到主屏幕,并且在“googlequicksearchbox”中不断崩溃。经过几个小时的搜索和技术支持,我发现了这一点。取消选中设置 - >开发者选项 - >不要保留活动,修复它。
答案 1 :(得分:0)
我拥有它!如果您在“设置”下查看,则会发生这种情况。开发者选项 - >不要保持活动。似乎拖拽层也被丢弃了。经验教训。