在添加Widget时,Launcher在Android Lollipop上崩溃,提供以下消息 (它在之前的Android版本上运行良好):
编辑:这只发生在横向上。
12-16 12:35:10.208: E/AndroidRuntime(960):
java.lang.RuntimeException: Unable to resume activity {com.android.launcher/com.android.launcher2.Launcher}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=5, result=-1, data=Intent { (has extras) }} to activity {com.android.launcher/com.android.launcher2.Launcher}: java.lang.NullPointerException: Attempt to read from field 'android.content.pm.ActivityInfo
android.appwidget.AppWidgetProviderInfo.providerInfo' on a null object reference
12-16 12:35:10.208: E/AndroidRuntime(960): at
android.appwidget.AppWidgetHostView.getRemoteContext(AppWidgetHostView.java:465)
12-16 12:35:10.208: E/AndroidRuntime(960): at
android.appwidget.AppWidgetHostView.updateAppWidget(AppWidgetHostView.java:376)
12-16 12:35:10.208: E/AndroidRuntime(960): at com.android.launcher2.LauncherAppWidgetHostView.updateAppWidget(LauncherAppWidgetHostView.java:54)
12-16 12:35:10.208: E/AndroidRuntime(960): at android.appwidget.AppWidgetHost.createView(AppWidgetHost.java:325)
12-16 12:35:10.208: E/AndroidRuntime(960): at com.android.launcher2.Launcher.completeTwoStageWidgetDrop(Launcher.java:703)
12-16 12:35:10.208: E/AndroidRuntime(960): at com.android.launcher2.Launcher.onActivityResult(Launcher.java:664)
这是提供商信息:
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="201dp"
android:minHeight="201dp"
android:updatePeriodMillis="180000"
android:initialLayout="@layout/appwidget_week"
android:configure="com.example.myApp.Widgets.Configure.WidgetConfigure_Week"
android:resizeMode="horizontal|vertical"
android:previewImage="@drawable/widget_screenshot_week"
android:label="@string/widget_week">
</appwidget-provider>
清单:
<receiver
android:name="com.example.myApp.Widgets.Provider.WidgetProvider_Week"
android:enabled="@bool/is_above_version_3_1"
android:label="@string/widget_week" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/appwidget_week_provider_info" />
</receiver>
答案 0 :(得分:0)
我在Marshmallow发生了类似的崩溃。在用于配置主屏幕小组件的活动中更改屏幕方向时发生了崩溃(如果方向未更改,则不会以任一方向发生)。
只是为了澄清:屏幕旋转时没有立即发生崩溃。相反,它发生在用户完成配置小部件,退出活动,Android正在创建主屏幕小部件的过程中。
这也导致了幻像小部件&#34;
。(即不在屏幕上显示但存在于Android中的小部件)。我能够通过在旋转设备时强制Widget配置活动保持纵向模式来解决此问题。如下所述: