Java Code Examples for io.flutter.view.FlutterMain#findAppBundlePath()

The following examples show how to use io.flutter.view.FlutterMain#findAppBundlePath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XFlutterActivityDelegate.java    From hybrid_stack_manager with MIT License 6 votes vote down vote up
private boolean loadIntent(Intent intent, boolean reuseIsolate) {
    String action = intent.getAction();
    if (Intent.ACTION_RUN.equals(action)) {
        String route = intent.getStringExtra("route");
        String appBundlePath = intent.getDataString();
        if (appBundlePath == null) {
            // Fall back to the installation path if no bundle path
            // was specified.
            appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
        }
        if (route != null) {
            flutterView.setInitialRoute(route);
        }
        flutterView.runFromBundle(appBundlePath, intent.getStringExtra("snapshot"), "main", reuseIsolate);
        return true;
    }

    return false;
}
 
Example 2
Source File: XFlutterActivityDelegate.java    From hybrid_stack_manager with MIT License 6 votes vote down vote up
private boolean loadIntent(Intent intent, boolean reuseIsolate) {
    String action = intent.getAction();
    if (Intent.ACTION_RUN.equals(action)) {
        String route = intent.getStringExtra("route");
        String appBundlePath = intent.getDataString();
        if (appBundlePath == null) {
            // Fall back to the installation path if no bundle path
            // was specified.
            appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
        }
        if (route != null) {
            flutterView.setInitialRoute(route);
        }
        flutterView.runFromBundle(appBundlePath, intent.getStringExtra("snapshot"), "main", reuseIsolate);
        return true;
    }

    return false;
}
 
Example 3
Source File: FlutterIsolatePlugin.java    From flutter_isolate with MIT License 5 votes vote down vote up
private void startNextIsolate() {

        IsolateHolder isolate = queuedIsolates.peek();

        FlutterMain.ensureInitializationComplete(context, null);

        if (flutterPluginBinding == null)
            isolate.view = new FlutterNativeView(context, true);
        else
            isolate.engine = new FlutterEngine(context);


        FlutterCallbackInformation cbInfo = FlutterCallbackInformation.lookupCallbackInformation(isolate.entryPoint);
        FlutterRunArguments runArgs = new FlutterRunArguments();

        runArgs.bundlePath = FlutterMain.findAppBundlePath(context);
        runArgs.libraryPath = cbInfo.callbackLibraryPath;
        runArgs.entrypoint = cbInfo.callbackName;

        if (flutterPluginBinding == null) {
            isolate.controlChannel = new MethodChannel(isolate.view, NAMESPACE + "/control");
            isolate.startupChannel = new EventChannel(isolate.view, NAMESPACE + "/event");
        } else {
            isolate.controlChannel = new MethodChannel(isolate.engine.getDartExecutor().getBinaryMessenger(), NAMESPACE + "/control");
            isolate.startupChannel = new EventChannel(isolate.engine.getDartExecutor().getBinaryMessenger(), NAMESPACE + "/event");
        }
        isolate.startupChannel.setStreamHandler(this);
        isolate.controlChannel.setMethodCallHandler(this);
        if (flutterPluginBinding == null) {
            registerWithRegistrant(isolate.view.getPluginRegistry());
            isolate.view.runFromBundle(runArgs);
        } else {
            DartExecutor.DartCallback dartCallback = new DartExecutor.DartCallback(context.getAssets(), runArgs.bundlePath, cbInfo);
            isolate.engine.getDartExecutor().executeDartCallback(dartCallback);
        }
    }
 
Example 4
Source File: XFlutterActivityDelegate.java    From hybrid_stack_manager with MIT License 5 votes vote down vote up
public void runFlutterBundle(){
    // When an activity is created for the first time, we direct the
    // FlutterView to re-use a pre-existing Isolate rather than create a new
    // one. This is so that an Isolate coming in from the ViewFactory is
    // used.
    final boolean reuseIsolate = true;

    if (loadIntent(activity.getIntent(), reuseIsolate)) {
        return;
    }
    String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
    if (appBundlePath != null) {
        flutterView.runFromBundle(appBundlePath, null, "main", reuseIsolate);
    }
}
 
Example 5
Source File: XFlutterActivityDelegate.java    From hybrid_stack_manager with MIT License 5 votes vote down vote up
public void runFlutterBundle(){
    // When an activity is created for the first time, we direct the
    // FlutterView to re-use a pre-existing Isolate rather than create a new
    // one. This is so that an Isolate coming in from the ViewFactory is
    // used.
    final boolean reuseIsolate = true;

    if (loadIntent(activity.getIntent(), reuseIsolate)) {
        return;
    }
    String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
    if (appBundlePath != null) {
        flutterView.runFromBundle(appBundlePath, null, "main", reuseIsolate);
    }
}