Class FlutterActivity.CachedEngineIntentBuilder
- Enclosing class:
- FlutterActivity
Intent
that launches a FlutterActivity
with an existing
FlutterEngine
that is cached in FlutterEngineCache
.-
Constructor Summary
ConstructorDescriptionCachedEngineIntentBuilder
(Class<? extends FlutterActivity> activityClass, String engineId) Constructor that allows thisCachedEngineIntentBuilder
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.destroyEngineWithActivity
(boolean destroyEngineWithActivity) Whether the cachedFlutterEngine
should be destroyed and removed from the cache when thisFlutterActivity
is destroyed.
-
Constructor Details
-
CachedEngineIntentBuilder
public CachedEngineIntentBuilder(@NonNull Class<? extends FlutterActivity> activityClass, @NonNull String engineId) Constructor that allows thisCachedEngineIntentBuilder
to be used by subclasses ofFlutterActivity
.Subclasses of
FlutterActivity
should provide their own static version ofFlutterActivity.withCachedEngine(String)
, which returns an instance ofCachedEngineIntentBuilder
constructed with aClass
reference to theFlutterActivity
subclass, e.g.:return new CachedEngineIntentBuilder(MyFlutterActivity.class, engineId);
- Parameters:
activityClass
- A subclass ofFlutterActivity
.engineId
- The engine id.
-
-
Method Details
-
destroyEngineWithActivity
public FlutterActivity.CachedEngineIntentBuilder destroyEngineWithActivity(boolean destroyEngineWithActivity) Whether the cachedFlutterEngine
should be destroyed and removed from the cache when thisFlutterActivity
is destroyed.The default value is
false
.- Parameters:
destroyEngineWithActivity
- Whether to destroy the engine.- Returns:
- The builder.
-
backgroundMode
@NonNull public FlutterActivity.CachedEngineIntentBuilder 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 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.
-