Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Package Functions | List of all members
io.flutter.embedding.android.FlutterActivity Class Reference
Inheritance diagram for io.flutter.embedding.android.FlutterActivity:
io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host io.flutter.embedding.android.FlutterEngineProvider io.flutter.embedding.android.FlutterEngineConfigurator io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithIntentBuilders io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithProvidedEngine

Classes

class  CachedEngineIntentBuilder
 
class  NewEngineInGroupIntentBuilder
 
class  NewEngineIntentBuilder
 

Public Member Functions

 FlutterActivity ()
 
ExclusiveAppComponent< Activity > getExclusiveAppComponent ()
 
void registerOnBackInvokedCallback ()
 
void unregisterOnBackInvokedCallback ()
 
void setFrameworkHandlesBack (boolean frameworkHandlesBack)
 
void onPostResume ()
 
void release ()
 
void detachFromFlutterEngine ()
 
void onBackPressed ()
 
void startBackGesture (@NonNull BackEvent backEvent)
 
void updateBackGestureProgress (@NonNull BackEvent backEvent)
 
void commitBackGesture ()
 
void cancelBackGesture ()
 
void onRequestPermissionsResult (int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
 
void onUserLeaveHint ()
 
void onWindowFocusChanged (boolean hasFocus)
 
void onTrimMemory (int level)
 
Context getContext ()
 
Activity getActivity ()
 
Lifecycle getLifecycle ()
 
FlutterShellArgs getFlutterShellArgs ()
 
String getCachedEngineId ()
 
String getCachedEngineGroupId ()
 
boolean shouldDestroyEngineWithHost ()
 
String getDartEntrypointFunctionName ()
 
List< String > getDartEntrypointArgs ()
 
String getDartEntrypointLibraryUri ()
 
String getInitialRoute ()
 
String getAppBundlePath ()
 
RenderMode getRenderMode ()
 
TransparencyMode getTransparencyMode ()
 
FlutterEngine provideFlutterEngine (@NonNull Context context)
 
PlatformPlugin providePlatformPlugin ( @Nullable Activity activity, @NonNull FlutterEngine flutterEngine)
 
void configureFlutterEngine (@NonNull FlutterEngine flutterEngine)
 
void cleanUpFlutterEngine (@NonNull FlutterEngine flutterEngine)
 
boolean shouldAttachEngineToActivity ()
 
boolean shouldHandleDeeplinking ()
 
void onFlutterSurfaceViewCreated (@NonNull FlutterSurfaceView flutterSurfaceView)
 
void onFlutterTextureViewCreated (@NonNull FlutterTextureView flutterTextureView)
 
void onFlutterUiDisplayed ()
 
void onFlutterUiNoLongerDisplayed ()
 
boolean shouldRestoreAndSaveState ()
 
boolean shouldDispatchAppLifecycleState ()
 
boolean attachToEngineAutomatically ()
 
boolean popSystemNavigator ()
 
void updateSystemUiOverlays ()
 

Static Public Member Functions

static Intent createDefaultIntent (@NonNull Context launchContext)
 
static NewEngineIntentBuilder withNewEngine ()
 
static CachedEngineIntentBuilder withCachedEngine (@NonNull String cachedEngineId)
 
static NewEngineInGroupIntentBuilder withNewEngineInGroup (@NonNull String engineGroupId)
 

Static Public Attributes

static final int FLUTTER_VIEW_ID = View.generateViewId()
 

Protected Member Functions

void onCreate (@Nullable Bundle savedInstanceState)
 
OnBackInvokedCallback getOnBackInvokedCallback ()
 
void onStart ()
 
void onResume ()
 
void onPause ()
 
void onStop ()
 
void onSaveInstanceState (Bundle outState)
 
void onDestroy ()
 
void onActivityResult (int requestCode, int resultCode, Intent data)
 
void onNewIntent (@NonNull Intent intent)
 
BackgroundMode getBackgroundMode ()
 
FlutterEngine getFlutterEngine ()
 
Bundle getMetaData () throws PackageManager.NameNotFoundException
 

Protected Attributes

FlutterActivityAndFragmentDelegate delegate
 

Package Functions

void setDelegate (@NonNull FlutterActivityAndFragmentDelegate delegate)
 

Detailed Description

Activity which displays a fullscreen Flutter UI.

FlutterActivity is the simplest and most direct way to integrate Flutter within an Android app.

FlutterActivity responsibilities

FlutterActivity maintains the following responsibilities:

Dart entrypoint, entrypoint arguments, initial route, and app bundle path

The Dart entrypoint executed within this Activity is "main()" by default. To change the entrypoint that a FlutterActivity executes, subclass FlutterActivity and override getDartEntrypointFunctionName(). For non-main Dart entrypoints to not be tree-shaken away, you need to annotate those functions with @pragma('vm:entry-point') in Dart.

The Dart entrypoint arguments will be passed as a list of string to Dart's entrypoint function. It can be passed using a NewEngineIntentBuilder via NewEngineIntentBuilder#dartEntrypointArgs.

The Flutter route that is initially loaded within this Activity is "/". The initial route may be specified explicitly by passing the name of the route as a String in FlutterActivityLaunchConfigs#EXTRA_INITIAL_ROUTE, e.g., "my/deep/link".

The initial route can each be controlled using a NewEngineIntentBuilder via NewEngineIntentBuilder#initialRoute.

The app bundle path, Dart entrypoint, Dart entrypoint arguments, and initial route can also be controlled in a subclass of FlutterActivity by overriding their respective methods:

The Dart entrypoint and app bundle path are not supported as Intent parameters since your Dart library entrypoints are your private APIs and Intents are invocable by other processes.

Using a cached FlutterEngine

FlutterActivity can be used with a cached io.flutter.embedding.engine.FlutterEngine instead of creating a new one. Use withCachedEngine(String) to build a FlutterActivity Intent that is configured to use an existing, cached io.flutter.embedding.engine.FlutterEngine. io.flutter.embedding.engine.FlutterEngineCache is the cache that is used to obtain a given cached io.flutter.embedding.engine.FlutterEngine. You must create and put a io.flutter.embedding.engine.FlutterEngine into the io.flutter.embedding.engine.FlutterEngineCache yourself before using the withCachedEngine(String) builder. An IllegalStateException will be thrown if a cached engine is requested but does not exist in the cache.

When using a cached io.flutter.embedding.engine.FlutterEngine, that io.flutter.embedding.engine.FlutterEngine should already be executing Dart code, which means that the Dart entrypoint and initial route have already been defined. Therefore, CachedEngineIntentBuilder does not offer configuration of these properties.

It is generally recommended to use a cached io.flutter.embedding.engine.FlutterEngine to avoid a momentary delay when initializing a new io.flutter.embedding.engine.FlutterEngine. The two exceptions to using a cached FlutterEngine are:

See https://flutter.dev/docs/development/add-to-app/performance for additional performance explorations on engine loading.

The following illustrates how to pre-warm and cache a io.flutter.embedding.engine.FlutterEngine:


// Create and pre-warm a FlutterEngine.
FlutterEngineGroup group = new FlutterEngineGroup(context);
FlutterEngine flutterEngine = group.createAndRunDefaultEngine(context);
flutterEngine.getDartExecutor().executeDartEntrypoint(DartEntrypoint.createDefault());

// Cache the pre-warmed FlutterEngine in the FlutterEngineCache.
FlutterEngineCache.getInstance().put("my_engine", flutterEngine);

Alternatives to FlutterActivity

If Flutter is needed in a location that cannot use an Activity, consider using a FlutterFragment. Using a FlutterFragment requires forwarding some calls from an Activity to the FlutterFragment.

If Flutter is needed in a location that can only use a View, consider using a FlutterView. Using a FlutterView requires forwarding some calls from an
Activity
, as well as forwarding lifecycle calls from an Activity or a Fragment.

Launch Screen

FlutterActivity supports the display of an Android "launch screen", which is displayed while the Android application loads. It is only applicable if FlutterActivity is the first Activity displayed upon loading the app.

Prior to Flutter 2.5, FlutterActivity supported the display of a Flutter-specific "splash screen" that would be displayed after the launch screen passes. This has since been deprecated. If a launch screen is specified, it will automatically persist for as long as it takes Flutter to initialize and render its first frame.

Use Android themes to display a launch screen. Create two themes: a launch theme and a normal theme. In the launch theme, set windowBackground to the desired Drawable for the launch screen. In the normal theme, set windowBackground to any desired background color that should normally appear behind your Flutter content. In most cases this background color will never be seen, but for possible transition edge cases it is a good idea to explicitly replace the launch screen window background with a neutral color.

Do not change aspects of system chrome between a launch theme and normal theme. Either define both themes to be fullscreen or not, and define both themes to display the same status bar and navigation bar settings. To adjust system chrome once the Flutter app renders, use platform channels to instruct Android to do so at the appropriate time. This will avoid any jarring visual changes during app startup.

In the AndroidManifest.xml, set the theme of FlutterActivity to the defined launch theme. In the metadata section for FlutterActivity, defined the following reference to your normal theme:

<meta-data android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/YourNormalTheme" />

With themes defined, and AndroidManifest.xml updated, Flutter displays the specified launch screen until the Android application is initialized.

Alternative Activity FlutterFragmentActivity is also available, which is similar to FlutterActivity but it extends FragmentActivity. You should use FlutterActivity, if possible, but if you need a FragmentActivity then you should use FlutterFragmentActivity.

Definition at line 211 of file FlutterActivity.java.

Constructor & Destructor Documentation

◆ FlutterActivity()

io.flutter.embedding.android.FlutterActivity.FlutterActivity ( )
inline

Definition at line 601 of file FlutterActivity.java.

601 {
602 lifecycle = new LifecycleRegistry(this);
603 }

Member Function Documentation

◆ attachToEngineAutomatically()

boolean io.flutter.embedding.android.FlutterActivity.attachToEngineAutomatically ( )
inline

Whether to automatically attach the FlutterView to the engine.

Returning false means that the task of attaching the FlutterView to the engine will be taken over by the host application.

Defaults to true.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1478 of file FlutterActivity.java.

1478 {
1479 return true;
1480 }

◆ cancelBackGesture()

void io.flutter.embedding.android.FlutterActivity.cancelBackGesture ( )
inline

Definition at line 957 of file FlutterActivity.java.

957 {
958 if (stillAttachedForEvent("cancelBackGesture")) {
960 }
961 }
FlutterActivityAndFragmentDelegate delegate

◆ cleanUpFlutterEngine()

void io.flutter.embedding.android.FlutterActivity.cleanUpFlutterEngine ( @NonNull FlutterEngine  flutterEngine)
inline

Hook for the host to cleanup references that were established in configureFlutterEngine(FlutterEngine) before the host is destroyed or detached.

This method is called in onDestroy().

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1346 of file FlutterActivity.java.

1346 {
1347 // No-op. Hook for subclasses.
1348 }

◆ commitBackGesture()

void io.flutter.embedding.android.FlutterActivity.commitBackGesture ( )
inline

Definition at line 949 of file FlutterActivity.java.

949 {
950 if (stillAttachedForEvent("commitBackGesture")) {
952 }
953 }

◆ configureFlutterEngine()

void io.flutter.embedding.android.FlutterActivity.configureFlutterEngine ( @NonNull FlutterEngine  flutterEngine)
inline

Hook for subclasses to easily configure a FlutterEngine.

This method is called after provideFlutterEngine(Context).

All plugins listed in the app's pubspec are registered in the base implementation of this method unless the FlutterEngine for this activity was externally created. To avoid the automatic plugin registration for implicitly created FlutterEngines, override this method without invoking super(). To keep automatic plugin registration and further configure the FlutterEngine, override this method, invoke super(), and then configure the FlutterEngine as desired.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1328 of file FlutterActivity.java.

1328 {
1329 if (delegate.isFlutterEngineFromHost()) {
1330 // If the FlutterEngine was explicitly built and injected into this FlutterActivity, the
1331 // builder should explicitly decide whether to automatically register plugins via the
1332 // FlutterEngine's construction parameter or via the AndroidManifest metadata.
1333 return;
1334 }
1335
1336 GeneratedPluginRegister.registerGeneratedPlugins(flutterEngine);
1337 }

◆ createDefaultIntent()

static Intent io.flutter.embedding.android.FlutterActivity.createDefaultIntent ( @NonNull Context  launchContext)
inlinestatic

Creates an Intent that launches a FlutterActivity, which creates a FlutterEngine that executes a main() Dart entrypoint, and displays the "/" route as Flutter's initial route.

Consider using the withCachedEngine(String) Intent builder to control when the io.flutter.embedding.engine.FlutterEngine should be created in your application.

Parameters
launchContextThe launch context. e.g. An Activity.
Returns
The default intent.

Definition at line 237 of file FlutterActivity.java.

237 {
238 return withNewEngine().build(launchContext);
239 }
static NewEngineIntentBuilder withNewEngine()

◆ detachFromFlutterEngine()

void io.flutter.embedding.android.FlutterActivity.detachFromFlutterEngine ( )
inline

Callback called when the io.flutter.embedding.engine.FlutterEngine has been attached to by another activity before this activity was destroyed.

The expected behavior is for this activity to synchronously stop using the FlutterEngine to avoid lifecycle crosstalk with the new activity.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 883 of file FlutterActivity.java.

883 {
884 Log.w(
885 TAG,
886 "FlutterActivity "
887 + this
888 + " connection to the engine "
890 + " evicted by another attaching activity");
891 if (delegate != null) {
894 }
895 }
void Log(const char *format,...) SK_PRINTF_LIKE(1

◆ getActivity()

Activity io.flutter.embedding.android.FlutterActivity.getActivity ( )
inline

FlutterActivityAndFragmentDelegate.Host method that is used by FlutterActivityAndFragmentDelegate to obtain an Activity reference as needed. This reference is used by the delegate to instantiate a FlutterView, a PlatformPlugin, and to determine if the Activity is changing configurations.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1012 of file FlutterActivity.java.

1012 {
1013 return this;
1014 }

◆ getAppBundlePath()

String io.flutter.embedding.android.FlutterActivity.getAppBundlePath ( )
inline

A custom path to the bundle that contains this Flutter app's resources, e.g., Dart code snapshots.

When this FlutterActivity is run by Flutter tooling and a data String is included in the launching Intent, that data String is interpreted as an app bundle path.

When otherwise unspecified, the value is null, which defaults to the app bundle path defined in io.flutter.embedding.engine.loader.FlutterLoader#findAppBundlePath().

Subclasses may override this method to return a custom app bundle path.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1206 of file FlutterActivity.java.

1206 {
1207 // If this Activity was launched from tooling, and the incoming Intent contains
1208 // a custom app bundle path, return that path.
1209 // TODO(mattcarroll): determine if we should have an explicit FlutterTestActivity instead of
1210 // conflating.
1211 if (isDebuggable() && Intent.ACTION_RUN.equals(getIntent().getAction())) {
1212 String appBundlePath = getIntent().getDataString();
1213 if (appBundlePath != null) {
1214 return appBundlePath;
1215 }
1216 }
1217
1218 return null;
1219 }

◆ getBackgroundMode()

BackgroundMode io.flutter.embedding.android.FlutterActivity.getBackgroundMode ( )
inlineprotected

The desired window background mode of this Activity, which defaults to BackgroundMode#opaque.

Returns
The background mode.

Definition at line 1261 of file FlutterActivity.java.

1261 {
1262 if (getIntent().hasExtra(EXTRA_BACKGROUND_MODE)) {
1263 return BackgroundMode.valueOf(getIntent().getStringExtra(EXTRA_BACKGROUND_MODE));
1264 } else {
1265 return BackgroundMode.opaque;
1266 }
1267 }

◆ getCachedEngineGroupId()

String io.flutter.embedding.android.FlutterActivity.getCachedEngineGroupId ( )
inline

Returns the ID of a statically cached io.flutter.embedding.engine.FlutterEngineGroup to use within this FlutterActivity, or null if this FlutterActivity does not want to use a cached io.flutter.embedding.engine.FlutterEngineGroup.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1056 of file FlutterActivity.java.

1056 {
1057 return getIntent().getStringExtra(EXTRA_CACHED_ENGINE_GROUP_ID);
1058 }

◆ getCachedEngineId()

String io.flutter.embedding.android.FlutterActivity.getCachedEngineId ( )
inline

Returns the ID of a statically cached io.flutter.embedding.engine.FlutterEngine to use within this FlutterActivity, or null if this FlutterActivity does not want to use a cached io.flutter.embedding.engine.FlutterEngine.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1045 of file FlutterActivity.java.

1045 {
1046 return getIntent().getStringExtra(EXTRA_CACHED_ENGINE_ID);
1047 }

◆ getContext()

Context io.flutter.embedding.android.FlutterActivity.getContext ( )
inline

FlutterActivityAndFragmentDelegate.Host method that is used by FlutterActivityAndFragmentDelegate to obtain a Context reference as needed.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1000 of file FlutterActivity.java.

1000 {
1001 return this;
1002 }

◆ getDartEntrypointArgs()

List< String > io.flutter.embedding.android.FlutterActivity.getDartEntrypointArgs ( )
inline

The Dart entrypoint arguments will be passed as a list of string to Dart's entrypoint function.

A value of null means do not pass any arguments to Dart's entrypoint function.

Subclasses may override this method to directly control the Dart entrypoint arguments.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1124 of file FlutterActivity.java.

1124 {
1125 return (List<String>) getIntent().getSerializableExtra(EXTRA_DART_ENTRYPOINT_ARGS);
1126 }

◆ getDartEntrypointFunctionName()

String io.flutter.embedding.android.FlutterActivity.getDartEntrypointFunctionName ( )
inline

The Dart entrypoint that will be executed as soon as the Dart snapshot is loaded.

This preference can be controlled with 2 methods:

  1. Pass a boolean as FlutterActivityLaunchConfigs#EXTRA_DART_ENTRYPOINT with the launching Intent, or
  2. Set a <meta-data> called FlutterActivityLaunchConfigs#DART_ENTRYPOINT_META_DATA_KEY within the Android manifest definition for this FlutterActivity

If both preferences are set, the Intent preference takes priority.

Subclasses may override this method to directly control the Dart entrypoint.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1101 of file FlutterActivity.java.

1101 {
1102 if (getIntent().hasExtra(EXTRA_DART_ENTRYPOINT)) {
1103 return getIntent().getStringExtra(EXTRA_DART_ENTRYPOINT);
1104 }
1105
1106 try {
1107 Bundle metaData = getMetaData();
1108 String desiredDartEntrypoint =
1109 metaData != null ? metaData.getString(DART_ENTRYPOINT_META_DATA_KEY) : null;
1110 return desiredDartEntrypoint != null ? desiredDartEntrypoint : DEFAULT_DART_ENTRYPOINT;
1111 } catch (PackageManager.NameNotFoundException e) {
1112 return DEFAULT_DART_ENTRYPOINT;
1113 }
1114 }

◆ getDartEntrypointLibraryUri()

String io.flutter.embedding.android.FlutterActivity.getDartEntrypointLibraryUri ( )
inline

The Dart library URI for the entrypoint that will be executed as soon as the Dart snapshot is loaded.

Example value: "package:foo/bar.dart"

This preference can be controlled by setting a <meta-data> called FlutterActivityLaunchConfigs#DART_ENTRYPOINT_URI_META_DATA_KEY within the Android manifest definition for this FlutterActivity.

A value of null means use the default root library.

Subclasses may override this method to directly control the Dart entrypoint uri.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1143 of file FlutterActivity.java.

1143 {
1144 try {
1145 Bundle metaData = getMetaData();
1146 String desiredDartLibraryUri =
1147 metaData != null ? metaData.getString(DART_ENTRYPOINT_URI_META_DATA_KEY) : null;
1148 return desiredDartLibraryUri;
1149 } catch (PackageManager.NameNotFoundException e) {
1150 return null;
1151 }
1152 }

◆ getExclusiveAppComponent()

ExclusiveAppComponent< Activity > io.flutter.embedding.android.FlutterActivity.getExclusiveAppComponent ( )
inline

Returns the Android App Component exclusively attached to io.flutter.embedding.engine.FlutterEngine.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 627 of file FlutterActivity.java.

627 {
628 return delegate;
629 }

◆ getFlutterEngine()

FlutterEngine io.flutter.embedding.android.FlutterActivity.getFlutterEngine ( )
inlineprotected

Hook for subclasses to obtain a reference to the io.flutter.embedding.engine.FlutterEngine that is owned by this FlutterActivity.

Returns
The Flutter engine.

Definition at line 1290 of file FlutterActivity.java.

◆ getFlutterShellArgs()

FlutterShellArgs io.flutter.embedding.android.FlutterActivity.getFlutterShellArgs ( )
inline

FlutterActivityAndFragmentDelegate.Host method that is used by FlutterActivityAndFragmentDelegate to obtain Flutter shell arguments when initializing Flutter.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1034 of file FlutterActivity.java.

1034 {
1035 return FlutterShellArgs.fromIntent(getIntent());
1036 }

◆ getInitialRoute()

String io.flutter.embedding.android.FlutterActivity.getInitialRoute ( )
inline

The initial route that a Flutter app will render upon loading and executing its Dart code.

This preference can be controlled with 2 methods:

  1. Pass a boolean as FlutterActivityLaunchConfigs#EXTRA_INITIAL_ROUTE with the launching Intent, or
  2. Set a <meta-data> called FlutterActivityLaunchConfigs#INITIAL_ROUTE_META_DATA_KEY for this Activity in the Android manifest.

If both preferences are set, the Intent preference takes priority.

The reason that a <meta-data> preference is supported is because this
Activity
might be the very first Activity launched, which means the developer won't have control over the incoming Intent.

Subclasses may override this method to directly control the initial route.

If this method returns null and the shouldHandleDeeplinking returns true, the initial route is derived from the Intent through the Intent.getData() instead.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1178 of file FlutterActivity.java.

1178 {
1179 if (getIntent().hasExtra(EXTRA_INITIAL_ROUTE)) {
1180 return getIntent().getStringExtra(EXTRA_INITIAL_ROUTE);
1181 }
1182
1183 try {
1184 Bundle metaData = getMetaData();
1185 String desiredInitialRoute =
1186 metaData != null ? metaData.getString(INITIAL_ROUTE_META_DATA_KEY) : null;
1187 return desiredInitialRoute;
1188 } catch (PackageManager.NameNotFoundException e) {
1189 return null;
1190 }
1191 }

◆ getLifecycle()

Lifecycle io.flutter.embedding.android.FlutterActivity.getLifecycle ( )
inline

FlutterActivityAndFragmentDelegate.Host method that is used by FlutterActivityAndFragmentDelegate to obtain a Lifecycle reference as needed. This reference is used by the delegate to provide Flutter plugins with access to lifecycle events.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1023 of file FlutterActivity.java.

1023 {
1024 return lifecycle;
1025 }

◆ getMetaData()

Bundle io.flutter.embedding.android.FlutterActivity.getMetaData ( ) throws PackageManager.NameNotFoundException
inlineprotected

Retrieves the meta data specified in the AndroidManifest.xml.

Returns
The meta data.
Exceptions
PackageManager.NameNotFoundExceptionif a package with the given name cannot be found on the system.

Definition at line 1302 of file FlutterActivity.java.

1302 {
1303 ActivityInfo activityInfo =
1304 getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA);
1305 return activityInfo.metaData;
1306 }

◆ getOnBackInvokedCallback()

OnBackInvokedCallback io.flutter.embedding.android.FlutterActivity.getOnBackInvokedCallback ( )
inlineprotected

Definition at line 688 of file FlutterActivity.java.

688 {
689 return onBackInvokedCallback;
690 }

◆ getRenderMode()

RenderMode io.flutter.embedding.android.FlutterActivity.getRenderMode ( )
inline

FlutterActivityAndFragmentDelegate.Host method that is used by FlutterActivityAndFragmentDelegate to obtain the desired RenderMode that should be used when instantiating a FlutterView.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1237 of file FlutterActivity.java.

1237 {
1238 return getBackgroundMode() == BackgroundMode.opaque ? RenderMode.surface : RenderMode.texture;
1239 }

◆ getTransparencyMode()

TransparencyMode io.flutter.embedding.android.FlutterActivity.getTransparencyMode ( )
inline

FlutterActivityAndFragmentDelegate.Host method that is used by FlutterActivityAndFragmentDelegate to obtain the desired TransparencyMode that should be used when instantiating a FlutterView.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1248 of file FlutterActivity.java.

1248 {
1249 return getBackgroundMode() == BackgroundMode.opaque
1250 ? TransparencyMode.opaque
1251 : TransparencyMode.transparent;
1252 }

◆ onActivityResult()

void io.flutter.embedding.android.FlutterActivity.onActivityResult ( int  requestCode,
int  resultCode,
Intent  data 
)
inlineprotected

Definition at line 909 of file FlutterActivity.java.

909 {
910 if (stillAttachedForEvent("onActivityResult")) {
911 delegate.onActivityResult(requestCode, resultCode, data);
912 }
913 }

◆ onBackPressed()

void io.flutter.embedding.android.FlutterActivity.onBackPressed ( )
inline

Definition at line 925 of file FlutterActivity.java.

925 {
926 if (stillAttachedForEvent("onBackPressed")) {
928 }
929 }

◆ onCreate()

void io.flutter.embedding.android.FlutterActivity.onCreate ( @Nullable Bundle  savedInstanceState)
inlineprotected

Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithProvidedEngine.

Definition at line 632 of file FlutterActivity.java.

632 {
633 switchLaunchThemeForNormalTheme();
634
635 super.onCreate(savedInstanceState);
636
637 delegate = new FlutterActivityAndFragmentDelegate(this);
638 delegate.onAttach(this);
639 delegate.onRestoreInstanceState(savedInstanceState);
640
641 lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
642
643 configureWindowForTransparency();
644
645 setContentView(createFlutterView());
646
647 configureStatusBarForFullscreenFlutterExperience();
648 }

◆ onDestroy()

void io.flutter.embedding.android.FlutterActivity.onDestroy ( )
inlineprotected

Definition at line 898 of file FlutterActivity.java.

898 {
899 super.onDestroy();
900 if (stillAttachedForEvent("onDestroy")) {
903 }
904 release();
905 lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY);
906 }

◆ onFlutterSurfaceViewCreated()

void io.flutter.embedding.android.FlutterActivity.onFlutterSurfaceViewCreated ( @NonNull FlutterSurfaceView  flutterSurfaceView)
inline

Invoked by this delegate when the FlutterSurfaceView that renders the Flutter UI is initially instantiated.

This method is only invoked if the io.flutter.embedding.android.FlutterView.RenderMode is set to io.flutter.embedding.android.FlutterView.RenderMode#surface. Otherwise, onFlutterTextureViewCreated(FlutterTextureView) is invoked.

This method is invoked before the given FlutterSurfaceView is attached to the View hierarchy. Implementers should not attempt to climb the View hierarchy or make assumptions about relationships with other Views.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1416 of file FlutterActivity.java.

1416 {
1417 // Hook for subclasses.
1418 }

◆ onFlutterTextureViewCreated()

void io.flutter.embedding.android.FlutterActivity.onFlutterTextureViewCreated ( @NonNull FlutterTextureView  flutterTextureView)
inline

Invoked by this delegate when the FlutterTextureView that renders the Flutter UI is initially instantiated.

This method is only invoked if the io.flutter.embedding.android.FlutterView.RenderMode is set to io.flutter.embedding.android.FlutterView.RenderMode#texture. Otherwise, onFlutterSurfaceViewCreated(FlutterSurfaceView) is invoked.

This method is invoked before the given FlutterTextureView is attached to the View hierarchy. Implementers should not attempt to climb the View hierarchy or make assumptions about relationships with other Views.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1421 of file FlutterActivity.java.

1421 {
1422 // Hook for subclasses.
1423 }

◆ onFlutterUiDisplayed()

void io.flutter.embedding.android.FlutterActivity.onFlutterUiDisplayed ( )
inline

Invoked by this delegate when its FlutterView starts painting pixels.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1426 of file FlutterActivity.java.

1426 {
1427 // Notifies Android that we're fully drawn so that performance metrics can be collected by
1428 // Flutter performance tests. A few considerations:
1429 // * reportFullyDrawn was supported in KitKat (API 19), but has a bug around requiring
1430 // permissions in some Android versions.
1431 // * reportFullyDrawn behavior isn't tested on pre-Q versions.
1432 // See https://github.com/flutter/flutter/issues/46172, and
1433 // https://github.com/flutter/flutter/issues/88767.
1434 if (Build.VERSION.SDK_INT >= API_LEVELS.API_29) {
1435 reportFullyDrawn();
1436 }
1437 }
Build(configs, env, options)
Definition build.py:232

◆ onFlutterUiNoLongerDisplayed()

void io.flutter.embedding.android.FlutterActivity.onFlutterUiNoLongerDisplayed ( )
inline

Invoked by this delegate when its FlutterView stops painting pixels.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1440 of file FlutterActivity.java.

1440 {
1441 // no-op
1442 }

◆ onNewIntent()

void io.flutter.embedding.android.FlutterActivity.onNewIntent ( @NonNull Intent  intent)
inlineprotected

Definition at line 916 of file FlutterActivity.java.

916 {
917 // TODO(mattcarroll): change G3 lint rule that forces us to call super
918 super.onNewIntent(intent);
919 if (stillAttachedForEvent("onNewIntent")) {
920 delegate.onNewIntent(intent);
921 }
922 }

◆ onPause()

void io.flutter.embedding.android.FlutterActivity.onPause ( )
inlineprotected

Definition at line 838 of file FlutterActivity.java.

838 {
839 super.onPause();
840 if (stillAttachedForEvent("onPause")) {
842 }
843 lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE);
844 }

◆ onPostResume()

void io.flutter.embedding.android.FlutterActivity.onPostResume ( )
inline

Definition at line 830 of file FlutterActivity.java.

830 {
831 super.onPostResume();
832 if (stillAttachedForEvent("onPostResume")) {
834 }
835 }

◆ onRequestPermissionsResult()

void io.flutter.embedding.android.FlutterActivity.onRequestPermissionsResult ( int  requestCode,
@NonNull String[]  permissions,
@NonNull int[]  grantResults 
)
inline

Definition at line 964 of file FlutterActivity.java.

965 {
966 if (stillAttachedForEvent("onRequestPermissionsResult")) {
967 delegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
968 }
969 }
void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)

◆ onResume()

void io.flutter.embedding.android.FlutterActivity.onResume ( )
inlineprotected

Definition at line 821 of file FlutterActivity.java.

821 {
822 super.onResume();
823 lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME);
824 if (stillAttachedForEvent("onResume")) {
826 }
827 }

◆ onSaveInstanceState()

void io.flutter.embedding.android.FlutterActivity.onSaveInstanceState ( Bundle  outState)
inlineprotected

Definition at line 856 of file FlutterActivity.java.

856 {
857 super.onSaveInstanceState(outState);
858 if (stillAttachedForEvent("onSaveInstanceState")) {
860 }
861 }

◆ onStart()

void io.flutter.embedding.android.FlutterActivity.onStart ( )
inlineprotected

Definition at line 812 of file FlutterActivity.java.

812 {
813 super.onStart();
814 lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START);
815 if (stillAttachedForEvent("onStart")) {
817 }
818 }

◆ onStop()

void io.flutter.embedding.android.FlutterActivity.onStop ( )
inlineprotected

Definition at line 847 of file FlutterActivity.java.

847 {
848 super.onStop();
849 if (stillAttachedForEvent("onStop")) {
851 }
852 lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_STOP);
853 }

◆ onTrimMemory()

void io.flutter.embedding.android.FlutterActivity.onTrimMemory ( int  level)
inline

Definition at line 987 of file FlutterActivity.java.

987 {
988 super.onTrimMemory(level);
989 if (stillAttachedForEvent("onTrimMemory")) {
990 delegate.onTrimMemory(level);
991 }
992 }

◆ onUserLeaveHint()

void io.flutter.embedding.android.FlutterActivity.onUserLeaveHint ( )
inline

Definition at line 972 of file FlutterActivity.java.

972 {
973 if (stillAttachedForEvent("onUserLeaveHint")) {
975 }
976 }

◆ onWindowFocusChanged()

void io.flutter.embedding.android.FlutterActivity.onWindowFocusChanged ( boolean  hasFocus)
inline

Definition at line 979 of file FlutterActivity.java.

979 {
980 super.onWindowFocusChanged(hasFocus);
981 if (stillAttachedForEvent("onWindowFocusChanged")) {
983 }
984 }

◆ popSystemNavigator()

boolean io.flutter.embedding.android.FlutterActivity.popSystemNavigator ( )
inline

Definition at line 1483 of file FlutterActivity.java.

1483 {
1484 // Hook for subclass. No-op if returns false.
1485 return false;
1486 }

◆ provideFlutterEngine()

FlutterEngine io.flutter.embedding.android.FlutterActivity.provideFlutterEngine ( @NonNull Context  context)
inline

Hook for subclasses to easily provide a custom io.flutter.embedding.engine.FlutterEngine.

This hook is where a cached io.flutter.embedding.engine.FlutterEngine should be provided, if a cached FlutterEngine is desired.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithProvidedEngine.

Definition at line 1278 of file FlutterActivity.java.

1278 {
1279 // No-op. Hook for subclasses.
1280 return null;
1281 }

◆ providePlatformPlugin()

PlatformPlugin io.flutter.embedding.android.FlutterActivity.providePlatformPlugin ( @Nullable Activity  activity,
@NonNull FlutterEngine  flutterEngine 
)
inline

Hook for the host to create/provide a PlatformPlugin if the associated Flutter experience should control system chrome.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1310 of file FlutterActivity.java.

1311 {
1312 return new PlatformPlugin(getActivity(), flutterEngine.getPlatformChannel(), this);
1313 }

◆ registerOnBackInvokedCallback()

void io.flutter.embedding.android.FlutterActivity.registerOnBackInvokedCallback ( )
inline

Registers the callback with OnBackInvokedDispatcher to capture back navigation gestures and pass them to the framework.

This replaces the deprecated onBackPressed method override in order to support API 33's predictive back navigation feature.

The callback must be unregistered in order to prevent unpredictable behavior once outside the Flutter app.

Definition at line 661 of file FlutterActivity.java.

661 {
662 if (Build.VERSION.SDK_INT >= API_LEVELS.API_33) {
663 getOnBackInvokedDispatcher()
664 .registerOnBackInvokedCallback(
665 OnBackInvokedDispatcher.PRIORITY_DEFAULT, onBackInvokedCallback);
666 hasRegisteredBackCallback = true;
667 }
668 }

◆ release()

void io.flutter.embedding.android.FlutterActivity.release ( )
inline

Irreversibly release this activity's control of the io.flutter.embedding.engine.FlutterEngine and its subcomponents.

Calling will disconnect this activity's view from the Flutter renderer, disconnect this activity from plugins' ActivityControlSurface, and stop system channel messages from this activity.

After calling, this activity should be disposed immediately and not be re-used.

Definition at line 874 of file FlutterActivity.java.

◆ setDelegate()

void io.flutter.embedding.android.FlutterActivity.setDelegate ( @NonNull FlutterActivityAndFragmentDelegate  delegate)
inlinepackage

This method exists so that JVM tests can ensure that a delegate exists without putting this Activity through any lifecycle events, because JVM tests cannot handle executing any lifecycle methods, at the time of writing this.

The testing infrastructure should be upgraded to make FlutterActivity tests easy to write while exercising real lifecycle methods. At such a time, this method should be removed.

Parameters
delegateThe delegate.

Definition at line 618 of file FlutterActivity.java.

618 {
619 this.delegate = delegate;
620 }

◆ setFrameworkHandlesBack()

void io.flutter.embedding.android.FlutterActivity.setFrameworkHandlesBack ( boolean  frameworkHandlesBack)
inline

Definition at line 724 of file FlutterActivity.java.

724 {
725 if (frameworkHandlesBack && !hasRegisteredBackCallback) {
727 } else if (!frameworkHandlesBack && hasRegisteredBackCallback) {
729 }
730 }

◆ shouldAttachEngineToActivity()

boolean io.flutter.embedding.android.FlutterActivity.shouldAttachEngineToActivity ( )
inline

Hook for subclasses to control whether or not the FlutterFragment within this
Activity
automatically attaches its io.flutter.embedding.engine.FlutterEngine to this Activity.

This property is controlled with a protected method instead of an Intent argument because the only situation where changing this value would help, is a situation in which
FlutterActivity
is being subclassed to utilize a custom and/or cached io.flutter.embedding.engine.FlutterEngine.

Defaults to true.

Control surfaces are used to provide Android resources and lifecycle events to plugins that are attached to the io.flutter.embedding.engine.FlutterEngine. If
shouldAttachEngineToActivity
is true, then this FlutterActivity will connect its io.flutter.embedding.engine.FlutterEngine to itself, along with any plugins that are registered with that io.flutter.embedding.engine.FlutterEngine. This allows plugins to access the Activity, as well as receive Activity-specific calls, e.g. Activity#onNewIntent(Intent). If shouldAttachEngineToActivity is false, then this FlutterActivity will not automatically manage the connection between its FlutterEngine and itself. In this case, plugins will not be offered a reference to an
Activity
or its OS hooks.

Returning false from this method does not preclude a io.flutter.embedding.engine.FlutterEngine from being attaching to a FlutterActivity - it just prevents the attachment from happening automatically. A developer can choose to subclass FlutterActivity and then invoke ActivityControlSurface#attachToActivity(ExclusiveAppComponent, Lifecycle) and ActivityControlSurface#detachFromActivity() at the desired times.

One reason that a developer might choose to manually manage the relationship between the Activity and io.flutter.embedding.engine.FlutterEngine is if the developer wants to move the FlutterEngine somewhere else. For example, a developer might want the io.flutter.embedding.engine.FlutterEngine to outlive this FlutterActivity so that it can be used later in a different Activity. To accomplish this, the io.flutter.embedding.engine.FlutterEngine may need to be disconnected from this
FlutterActivity
at an unusual time, preventing this FlutterActivity from correctly managing the relationship between the io.flutter.embedding.engine.FlutterEngine and itself.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1391 of file FlutterActivity.java.

1391 {
1392 return true;
1393 }

◆ shouldDestroyEngineWithHost()

boolean io.flutter.embedding.android.FlutterActivity.shouldDestroyEngineWithHost ( )
inline

Returns false if the io.flutter.embedding.engine.FlutterEngine backing this
FlutterActivity
should outlive this FlutterActivity, or true to be destroyed when the FlutterActivity is destroyed.

The default value is true in cases where FlutterActivity created its own io.flutter.embedding.engine.FlutterEngine, and false in cases where a cached io.flutter.embedding.engine.FlutterEngine was provided.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1070 of file FlutterActivity.java.

1070 {
1071 boolean explicitDestructionRequested =
1072 getIntent().getBooleanExtra(EXTRA_DESTROY_ENGINE_WITH_ACTIVITY, false);
1073 if (getCachedEngineId() != null || delegate.isFlutterEngineFromHost()) {
1074 // Only destroy a cached engine if explicitly requested by app developer.
1075 return explicitDestructionRequested;
1076 } else {
1077 // If this Activity created the FlutterEngine, destroy it by default unless
1078 // explicitly requested not to.
1079 return getIntent().getBooleanExtra(EXTRA_DESTROY_ENGINE_WITH_ACTIVITY, true);
1080 }
1081 }

◆ shouldDispatchAppLifecycleState()

boolean io.flutter.embedding.android.FlutterActivity.shouldDispatchAppLifecycleState ( )
inline

Give the host application a chance to take control of the app lifecycle events.

Return false means the host application dispatches these app lifecycle events, while return true means the engine dispatches these events.

Defaults to true.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1465 of file FlutterActivity.java.

1465 {
1466 return true;
1467 }

◆ shouldHandleDeeplinking()

boolean io.flutter.embedding.android.FlutterActivity.shouldHandleDeeplinking ( )
inline

Whether to handle the deeplinking from the Intent automatically if the
getInitialRoute
returns null.

The default implementation looks <meta-data> called FlutterActivityLaunchConfigs#HANDLE_DEEPLINKING_META_DATA_KEY within the Android manifest definition for this FlutterActivity.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1404 of file FlutterActivity.java.

1404 {
1405 try {
1406 Bundle metaData = getMetaData();
1407 boolean shouldHandleDeeplinking =
1408 metaData != null ? metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY) : false;
1410 } catch (PackageManager.NameNotFoundException e) {
1411 return false;
1412 }
1413 }

◆ shouldRestoreAndSaveState()

boolean io.flutter.embedding.android.FlutterActivity.shouldRestoreAndSaveState ( )
inline

Whether state restoration is enabled.

When this returns true, the instance state provided to
onRestoreInstanceState(Bundle)
will be forwarded to the framework via the
RestorationChannel
and during onSaveInstanceState(Bundle) the current framework instance state obtained from RestorationChannel will be stored in the provided bundle.

This defaults to true, unless a cached engine is used.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1445 of file FlutterActivity.java.

1445 {
1446 if (getIntent().hasExtra(EXTRA_ENABLE_STATE_RESTORATION)) {
1447 return getIntent().getBooleanExtra(EXTRA_ENABLE_STATE_RESTORATION, false);
1448 }
1449 if (getCachedEngineId() != null) {
1450 // Prevent overwriting the existing state in a cached engine with restoration state.
1451 return false;
1452 }
1453 return true;
1454 }

◆ startBackGesture()

void io.flutter.embedding.android.FlutterActivity.startBackGesture ( @NonNull BackEvent  backEvent)
inline

Definition at line 933 of file FlutterActivity.java.

933 {
934 if (stillAttachedForEvent("startBackGesture")) {
935 delegate.startBackGesture(backEvent);
936 }
937 }

◆ unregisterOnBackInvokedCallback()

void io.flutter.embedding.android.FlutterActivity.unregisterOnBackInvokedCallback ( )
inline

Unregisters the callback from OnBackInvokedDispatcher.

This should be called when the activity is no longer in use to prevent unpredictable behavior such as being stuck and unable to press back.

Definition at line 677 of file FlutterActivity.java.

677 {
678 if (Build.VERSION.SDK_INT >= API_LEVELS.API_33) {
679 getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback(onBackInvokedCallback);
680 hasRegisteredBackCallback = false;
681 }
682 }

◆ updateBackGestureProgress()

void io.flutter.embedding.android.FlutterActivity.updateBackGestureProgress ( @NonNull BackEvent  backEvent)
inline

Definition at line 941 of file FlutterActivity.java.

941 {
942 if (stillAttachedForEvent("updateBackGestureProgress")) {
944 }
945 }

◆ updateSystemUiOverlays()

void io.flutter.embedding.android.FlutterActivity.updateSystemUiOverlays ( )
inline

Refreshes Android's window system UI (AKA system chrome) to match Flutter's desired system chrome style.

This is useful when using the splash screen API available in Android 12.
SplashScreenView#remove
resets the system UI colors to the values set prior to the execution of the Dart entrypoint. As a result, the values set from Dart are reverted by this API. To workaround this issue, call this method after removing the splash screen with
SplashScreenView#remove
.

Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.

Definition at line 1489 of file FlutterActivity.java.

◆ withCachedEngine()

static CachedEngineIntentBuilder io.flutter.embedding.android.FlutterActivity.withCachedEngine ( @NonNull String  cachedEngineId)
inlinestatic

Creates a CachedEngineIntentBuilder, which can be used to configure an Intent to launch a FlutterActivity that internally uses an existing io.flutter.embedding.engine.FlutterEngine that is cached in io.flutter.embedding.engine.FlutterEngineCache.

Parameters
cachedEngineIdA cached engine ID.
Returns
The builder.

Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithIntentBuilders.

Definition at line 361 of file FlutterActivity.java.

361 {
362 return new CachedEngineIntentBuilder(FlutterActivity.class, cachedEngineId);
363 }

◆ withNewEngine()

static NewEngineIntentBuilder io.flutter.embedding.android.FlutterActivity.withNewEngine ( )
inlinestatic

Creates an NewEngineIntentBuilder, which can be used to configure an Intent to launch a FlutterActivity that internally creates a new io.flutter.embedding.engine.FlutterEngine using the desired Dart entrypoint, initial route, etc.

Returns
The engine intent builder.

Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithIntentBuilders.

Definition at line 250 of file FlutterActivity.java.

250 {
251 return new NewEngineIntentBuilder(FlutterActivity.class);
252 }

◆ withNewEngineInGroup()

static NewEngineInGroupIntentBuilder io.flutter.embedding.android.FlutterActivity.withNewEngineInGroup ( @NonNull String  engineGroupId)
inlinestatic

Creates a NewEngineInGroupIntentBuilder, which can be used to configure an Intent to launch a FlutterActivity by internally creating a FlutterEngine from an existing io.flutter.embedding.engine.FlutterEngineGroup cached in a specified io.flutter.embedding.engine.FlutterEngineGroupCache.


// 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);

// Start a FlutterActivity with the FlutterEngineGroup by creating an intent with withNewEngineInGroup
Intent intent = FlutterActivity.withNewEngineInGroup("my_cached_engine_group_id")
.dartEntrypoint("custom_entrypoint")
.initialRoute("/custom/route")
.backgroundMode(BackgroundMode.transparent)
.build(context);
startActivity(intent);
Parameters
engineGroupIdA cached engine group ID.
Returns
The builder.

Definition at line 474 of file FlutterActivity.java.

474 {
475 return new NewEngineInGroupIntentBuilder(FlutterActivity.class, engineGroupId);
476 }

Member Data Documentation

◆ delegate

FlutterActivityAndFragmentDelegate io.flutter.embedding.android.FlutterActivity.delegate
protected

Definition at line 597 of file FlutterActivity.java.

◆ FLUTTER_VIEW_ID

final int io.flutter.embedding.android.FlutterActivity.FLUTTER_VIEW_ID = View.generateViewId()
static

The ID of the FlutterView created by this activity.

This ID can be used to lookup FlutterView in the Android view hierarchy. For more, see android.view.View#findViewById.

Definition at line 223 of file FlutterActivity.java.


The documentation for this class was generated from the following file: