Prevent crash when a bad widget launches a non-existent config activity.
This commit is contained in:
1 parent
4f20947fd6
commit
8e633c5a3e
1 file changed
+14
-1
@@ -997,7 +997,7 @@ public final class Launcher extends Activity
|
||||
intent.setComponent(appWidget.configure);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
|
||||
startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
|
||||
startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
|
||||
} else {
|
||||
// Otherwise just add it
|
||||
onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
|
||||
@@ -1284,6 +1284,19 @@ public final class Launcher extends Activity
|
||||
"or use the exported attribute for this activity.", e);
|
||||
}
|
||||
}
|
||||
|
||||
void startActivityForResultSafely(Intent intent, int requestCode) {
|
||||
try {
|
||||
startActivityForResult(intent, requestCode);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
||||
} catch (SecurityException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
|
||||
Log.e(TAG, "Launcher does not have the permission to launch " + intent +
|
||||
". Make sure to create a MAIN intent-filter for the corresponding activity " +
|
||||
"or use the exported attribute for this activity.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFolderClick(FolderInfo folderInfo) {
|
||||
if (!folderInfo.opened) {
|
||||
|
||||
Reference in new issue
Block a user