My users report crashes when they try to select a widget with my application (not an application to launch). I use the standard widget selection code, and it always worked and works on all devices except LG G2 and LG G3 .
I found several similar questions, but they all relate to the crash that Android 2.1 encountered, which was resolved using an empty informational workaround (which is already implemented in my code).
An alternative method is also used to get widgets without official choice - which works, but requires the application to be a system application for permission BIND_APPWIDGET.
Has anyone also experienced this problem and possibly found a workaround or solution?
thanks
Here is the code:
public static void selectWidget(AppWidgetHost appWidgetHost, final Activity activity) { try { int appWidgetId = appWidgetHost.allocateAppWidgetId(); Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK); pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); addEmptyData(pickIntent); activity.startActivityForResult(pickIntent, R.id.REQUEST_PICK_APPWIDGET); } catch (ActivityNotFoundException e) { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, activity.getString(R.string.widget_config_no_activity), Toast.LENGTH_SHORT).show(); } }); } } private static void addEmptyData(Intent pickIntent) { ArrayList customInfo = new ArrayList(); pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, customInfo); ArrayList customExtras = new ArrayList(); pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, customExtras); }
Here's the crash stacktrace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.AppWidgetPickActivity}: android.content.res.Resources$NotFoundException: File res/drawable-xhdpi-1280x960/ic_launcher_calendar.png from drawable resource ID
source share