Class FlutterActivity.NewEngineInGroupIntentBuilder
- Enclosing class:
- FlutterActivity
Intent
that launches a FlutterActivity
with a new FlutterEngine
created by FlutterEngineGroup#createAndRunEngine.-
Constructor Summary
ConstructorDescriptionNewEngineInGroupIntentBuilder
(Class<? extends FlutterActivity> activityClass, String engineGroupId) Constructor that allows thisNewEngineInGroupIntentBuilder
to be used by subclasses ofFlutterActivity
. -
Method Summary
Modifier and TypeMethodDescriptionbackgroundMode
(FlutterActivityLaunchConfigs.BackgroundMode backgroundMode) The mode ofFlutterActivity
's background, eitherFlutterActivityLaunchConfigs.BackgroundMode.opaque
orFlutterActivityLaunchConfigs.BackgroundMode.transparent
.Creates and returns anIntent
that will launch aFlutterActivity
with 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 thisNewEngineInGroupIntentBuilder
to be used by subclasses ofFlutterActivity
.Subclasses of
FlutterActivity
should provide their own static version ofFlutterActivity.withNewEngineInGroup(java.lang.String)
, which returns an instance ofNewEngineInGroupIntentBuilder
constructed with aClass
reference to theFlutterActivity
subclass, 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.opaque
orFlutterActivityLaunchConfigs.BackgroundMode.transparent
.The default background mode is
FlutterActivityLaunchConfigs.BackgroundMode.opaque
.Choosing a background mode of
FlutterActivityLaunchConfigs.BackgroundMode.transparent
will configure the innerFlutterView
of thisFlutterActivity
to be configured with aFlutterTextureView
to 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
FlutterActivity
that is configured with a background mode ofFlutterActivityLaunchConfigs.BackgroundMode.transparent
must 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 anIntent
that will launch aFlutterActivity
with the desired configuration.- Parameters:
context
- The context. e.g. An Activity.- Returns:
- The intent.
-