Activity.startActivityForResult(): use internalCreateActivity helper method

This commit is contained in:
Julian Winkler
2025-01-11 17:44:35 +01:00
parent a4c14c9cd1
commit 6be60574aa

View File

@@ -321,11 +321,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
Slog.i(TAG, "startActivityForResult(" + intent + ", " + requestCode + "," + options + ") called"); Slog.i(TAG, "startActivityForResult(" + intent + ", " + requestCode + "," + options + ") called");
if (intent.getComponent() != null) { if (intent.getComponent() != null) {
try { try {
Class<? extends Activity> cls = Class.forName(intent.getComponent().getClassName()).asSubclass(Activity.class); final Activity activity = internalCreateActivity(intent.getComponent().getClassName(), getWindow().native_window, intent);
Constructor<? extends Activity> constructor = cls.getConstructor();
final Activity activity = constructor.newInstance();
activity.intent = intent;
activity.getWindow().native_window = getWindow().native_window;
activity.resultRequestCode = requestCode; activity.resultRequestCode = requestCode;
activity.resultActivity = this; activity.resultActivity = this;
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@@ -334,7 +330,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
nativeStartActivity(activity); nativeStartActivity(activity);
} }
}); });
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } catch (ReflectiveOperationException e) {
onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent()); onActivityResult(requestCode, 0 /*RESULT_CANCELED*/, new Intent());
} }
} else if (FILE_CHOOSER_ACTIONS.contains(intent.getAction())) { } else if (FILE_CHOOSER_ACTIONS.contains(intent.getAction())) {