Class FlutterActivity.NewEngineInGroupIntentBuilder
- Enclosing class:
- FlutterActivity
Intent that launches a FlutterActivity with a new FlutterEngine created by FlutterEngineGroup#createAndRunEngine.-
Constructor Summary
ConstructorsConstructorDescriptionNewEngineInGroupIntentBuilder(Class<? extends FlutterActivity> activityClass, String engineGroupId) Constructor that allows thisNewEngineInGroupIntentBuilderto be used by subclasses ofFlutterActivity. -
Method Summary
Modifier and TypeMethodDescriptionbackgroundMode(FlutterActivityLaunchConfigs.BackgroundMode backgroundMode) The mode ofFlutterActivity's background, eitherFlutterActivityLaunchConfigs.BackgroundMode.opaqueorFlutterActivityLaunchConfigs.BackgroundMode.transparent.Creates and returns anIntentthat will launch aFlutterActivitywith the desired configuration.dartEntrypoint(String dartEntrypoint) The Dart entrypoint that will be executed in the newly created FlutterEngine as soon as the Dart snapshot is loaded.initialRoute(String initialRoute) The initial route that a Flutter app will render in thisFlutterActivity, defaults to "/".
-
Constructor Details
-
NewEngineInGroupIntentBuilder
public NewEngineInGroupIntentBuilder(@NonNull Class<? extends FlutterActivity> activityClass, @NonNull String engineGroupId) Constructor that allows thisNewEngineInGroupIntentBuilderto be used by subclasses ofFlutterActivity.Subclasses of
FlutterActivityshould provide their own static version ofFlutterActivity.withNewEngineInGroup(java.lang.String), which returns an instance ofNewEngineInGroupIntentBuilderconstructed with aClassreference to theFlutterActivitysubclass, e.g.:return new NewEngineInGroupIntentBuilder(MyFlutterActivity.class, cacheedEngineGroupId);// Create a FlutterEngineGroup, such as in the onCreate method of the Application. FlutterEngineGroup engineGroup = new FlutterEngineGroup(this); FlutterEngineGroupCache.getInstance().put("my_cached_engine_group_id", engineGroup); // Create a NewEngineInGroupIntentBuilder that would build an intent to start my custom FlutterActivity subclass. FlutterActivity.NewEngineInGroupIntentBuilder intentBuilder = new FlutterActivity.NewEngineInGroupIntentBuilder( MyFlutterActivity.class, app.engineGroupId); intentBuilder.dartEntrypoint("main") .initialRoute("/custom/route") .backgroundMode(BackgroundMode.transparent); startActivity(intentBuilder.build(context));- Parameters:
activityClass- A subclass ofFlutterActivity.engineGroupId- The engine group id.
-
-
Method Details
-
dartEntrypoint
@NonNull public FlutterActivity.NewEngineInGroupIntentBuilder dartEntrypoint(@NonNull String dartEntrypoint) The Dart entrypoint that will be executed in the newly created FlutterEngine as soon as the Dart snapshot is loaded. Default to "main".- Parameters:
dartEntrypoint- The dart entrypoint's name- Returns:
- The engine group intent builder
-
initialRoute
@NonNull public FlutterActivity.NewEngineInGroupIntentBuilder initialRoute(@NonNull String initialRoute) The initial route that a Flutter app will render in thisFlutterActivity, defaults to "/".- Parameters:
initialRoute- The route.- Returns:
- The engine group intent builder.
-
backgroundMode
@NonNull public FlutterActivity.NewEngineInGroupIntentBuilder backgroundMode(@NonNull FlutterActivityLaunchConfigs.BackgroundMode backgroundMode) The mode ofFlutterActivity's background, eitherFlutterActivityLaunchConfigs.BackgroundMode.opaqueorFlutterActivityLaunchConfigs.BackgroundMode.transparent.The default background mode is
FlutterActivityLaunchConfigs.BackgroundMode.opaque.Choosing a background mode of
FlutterActivityLaunchConfigs.BackgroundMode.transparentwill configure the innerFlutterViewof thisFlutterActivityto be configured with aFlutterTextureViewto support transparency. This choice has a non-trivial performance impact. A transparent background should only be used if it is necessary for the app design being implemented.A
FlutterActivitythat is configured with a background mode ofFlutterActivityLaunchConfigs.BackgroundMode.transparentmust have a theme applied to it that includes the following property:<item name="android:windowIsTranslucent">true</item>.- Parameters:
backgroundMode- The background mode.- Returns:
- The engine group intent builder.
-
build
Creates and returns anIntentthat will launch aFlutterActivitywith the desired configuration.- Parameters:
context- The context. e.g. An Activity.- Returns:
- The intent.
-