diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 9e06e8f384de3..2a4c924c50d9d 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -167,19 +167,9 @@ public void onCreate(Bundle savedInstanceState) { return; } - if (!flutterView.getFlutterNativeView().isApplicationRunning()) { - String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext()); - if (appBundlePath != null) { - FlutterRunArguments arguments = new FlutterRunArguments(); - ArrayList bundlePaths = new ArrayList<>(); - if (FlutterMain.getUpdateInstallationPath() != null) { - bundlePaths.add(FlutterMain.getUpdateInstallationPath()); - } - bundlePaths.add(appBundlePath); - arguments.bundlePaths = bundlePaths.toArray(new String[0]); - arguments.entrypoint = "main"; - flutterView.runFromBundle(arguments); - } + String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext()); + if (appBundlePath != null) { + runBundle(appBundlePath); } } @@ -335,30 +325,34 @@ private boolean loadIntent(Intent intent) { String route = intent.getStringExtra("route"); String appBundlePath = intent.getDataString(); if (appBundlePath == null) { - // Fall back to the installation path if no bundle path - // was specified. + // Fall back to the installation path if no bundle path was specified. appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext()); } if (route != null) { flutterView.setInitialRoute(route); } - if (!flutterView.getFlutterNativeView().isApplicationRunning()) { - FlutterRunArguments args = new FlutterRunArguments(); - ArrayList bundlePaths = new ArrayList<>(); - if (FlutterMain.getUpdateInstallationPath() != null) { - bundlePaths.add(FlutterMain.getUpdateInstallationPath()); - } - bundlePaths.add(appBundlePath); - args.bundlePaths = bundlePaths.toArray(new String[0]); - args.entrypoint = "main"; - flutterView.runFromBundle(args); - } + + runBundle(appBundlePath); return true; } return false; } + private void runBundle(String appBundlePath) { + if (!flutterView.getFlutterNativeView().isApplicationRunning()) { + FlutterRunArguments args = new FlutterRunArguments(); + ArrayList bundlePaths = new ArrayList<>(); + if (FlutterMain.getUpdateInstallationPath() != null) { + bundlePaths.add(FlutterMain.getUpdateInstallationPath()); + } + bundlePaths.add(appBundlePath); + args.bundlePaths = bundlePaths.toArray(new String[0]); + args.entrypoint = "main"; + flutterView.runFromBundle(args); + } + } + /** * Creates a {@link View} containing the same {@link Drawable} as the one set as the * {@code windowBackground} of the parent activity for use as a launch splash view.