Android Lollipop: Launcher crashes when you add an application widget to the home screen

Launcher crashes on Android Lollipop when a widget is added that shows the following message: (It works fine in previous versions of Android):

Edit: this only happens in landscape orientation.

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) 

This is the information about the provider:

 <?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> 

And the manifest:

  <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> 
+5
source share
1 answer

I had a similar crash on Zephyr. My failure occurred when the screen orientation was changed during the action used to configure the widget on the main screen (this did not happen in any orientation if the orientation was not changed).

Just to clarify: the accident did not happen immediately when the screen was rotated. Rather, this happened after the user finished configuring the widget, exited Activity, and Android started creating the Home Screen widget.

This also caused the appearance of “phantom widgets” (ie widgets that do not appear on the screen but exist inside Android).

I managed to resolve it by forcing the widget settings activity to remain in portrait mode when the device was rotated. As described here:

Power "portrait" orientation mode

0
source

Source: https://habr.com/ru/post/1209227/


All Articles