Flutter Engine
The Flutter Engine
|
Classes | |
class | CachedEngineIntentBuilder |
class | NewEngineInGroupIntentBuilder |
class | NewEngineIntentBuilder |
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) |
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:
Activity
transparently, if desired. io.flutter.embedding.engine.FlutterEngine
. #shouldRestoreAndSaveState()
; 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:
FlutterActivity
is the first Activity
displayed by the app, because pre-warming a io.flutter.embedding.engine.FlutterEngine
would have no impact in this situation. 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
, as well as forwarding lifecycle calls from an
ActivityActivity
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.
|
inline |
Definition at line 601 of file FlutterActivity.java.
|
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.
|
inline |
Definition at line 957 of file FlutterActivity.java.
|
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.
|
inline |
Definition at line 949 of file FlutterActivity.java.
|
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.
Reimplemented in dev.flutter.scenarios.PlatformViewsActivity, and dev.flutter.scenarios.TestableFlutterActivity.
Definition at line 1328 of file FlutterActivity.java.
|
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.
launchContext | The launch context. e.g. An Activity. |
Definition at line 237 of file FlutterActivity.java.
|
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.
|
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.
|
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.
|
inlineprotected |
The desired window background mode of this Activity
, which defaults to BackgroundMode#opaque
.
Definition at line 1261 of file FlutterActivity.java.
|
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.
|
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.
|
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.
|
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.
|
inline |
The Dart entrypoint that will be executed as soon as the Dart snapshot is loaded.
This preference can be controlled with 2 methods:
FlutterActivityLaunchConfigs#EXTRA_DART_ENTRYPOINT
with the launching Intent
, or <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.
|
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.
|
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.
|
inlineprotected |
Hook for subclasses to obtain a reference to the io.flutter.embedding.engine.FlutterEngine
that is owned by this FlutterActivity
.
Definition at line 1290 of file FlutterActivity.java.
|
inline |
FlutterActivityAndFragmentDelegate.Host
method that is used by FlutterActivityAndFragmentDelegate
to obtain Flutter shell arguments when initializing Flutter.
Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.
Reimplemented in dev.flutter.scenarios.TestActivity.
Definition at line 1034 of file FlutterActivity.java.
|
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:
FlutterActivityLaunchConfigs#EXTRA_INITIAL_ROUTE
with the launching Intent
, or <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
might be the very first
ActivityActivity
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.
|
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.
|
inlineprotected |
Retrieves the meta data specified in the AndroidManifest.xml.
PackageManager.NameNotFoundException | if a package with the given name cannot be found on the system. |
Definition at line 1302 of file FlutterActivity.java.
|
inlineprotected |
Definition at line 688 of file FlutterActivity.java.
|
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.
|
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.
|
inlineprotected |
Definition at line 909 of file FlutterActivity.java.
|
inline |
Definition at line 925 of file FlutterActivity.java.
|
inlineprotected |
Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithProvidedEngine, dev.flutter.scenarios.ExternalTextureFlutterActivity, dev.flutter.scenarios.TestableFlutterActivity, and dev.flutter.scenarios.TestActivity.
Definition at line 632 of file FlutterActivity.java.
|
inlineprotected |
Reimplemented in dev.flutter.scenarios.TestActivity.
Definition at line 898 of file FlutterActivity.java.
|
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 View
s.
Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.
Definition at line 1416 of file FlutterActivity.java.
|
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 View
s.
Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.
Definition at line 1421 of file FlutterActivity.java.
|
inline |
Invoked by this delegate when its FlutterView
starts painting pixels.
Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.
Reimplemented in dev.flutter.scenarios.ExternalTextureFlutterActivity, and dev.flutter.scenarios.TestActivity.
Definition at line 1426 of file FlutterActivity.java.
|
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.
|
inlineprotected |
Definition at line 916 of file FlutterActivity.java.
|
inlineprotected |
Reimplemented in dev.flutter.scenarios.ExternalTextureFlutterActivity.
Definition at line 838 of file FlutterActivity.java.
|
inline |
Definition at line 830 of file FlutterActivity.java.
|
inline |
Definition at line 964 of file FlutterActivity.java.
|
inlineprotected |
Definition at line 821 of file FlutterActivity.java.
|
inlineprotected |
Definition at line 856 of file FlutterActivity.java.
|
inlineprotected |
Definition at line 812 of file FlutterActivity.java.
|
inlineprotected |
Definition at line 847 of file FlutterActivity.java.
|
inline |
Definition at line 987 of file FlutterActivity.java.
|
inline |
Definition at line 972 of file FlutterActivity.java.
|
inline |
Definition at line 979 of file FlutterActivity.java.
|
inline |
Allow implementer to customize the behavior needed when the Flutter framework calls to pop the Android-side navigation stack.
androidx.activity.OnBackPressedDispatcher
will be executed. Implements io.flutter.plugin.platform.PlatformPlugin.PlatformPluginDelegate.
Definition at line 1483 of file FlutterActivity.java.
|
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, dev.flutter.scenarios.SpawnedEngineActivity, and dev.flutter.scenarios.SpawnMultiEngineActivity.
Definition at line 1278 of file FlutterActivity.java.
|
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.
|
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.
|
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.
|
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.
delegate | The delegate. |
Definition at line 618 of file FlutterActivity.java.
|
inline |
The Flutter application would or would not like to handle navigation pop events itself.
Relevant for registering and unregistering the app's OnBackInvokedCallback for the Predictive Back feature, for example as in io.flutter.embedding.android.FlutterActivity
.
Implements io.flutter.plugin.platform.PlatformPlugin.PlatformPluginDelegate.
Definition at line 724 of file FlutterActivity.java.
|
inline |
Hook for subclasses to control whether or not the FlutterFragment
within this
automatically attaches its
Activityio.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
is being subclassed to utilize a custom and/or cached
FlutterActivityio.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
is true, then this
shouldAttachEngineToActivityFlutterActivity
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
or its OS hooks.
Activity
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
at an unusual time, preventing this
FlutterActivityFlutterActivity
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.
|
inline |
Returns false if the io.flutter.embedding.engine.FlutterEngine
backing this
should outlive this
FlutterActivityFlutterActivity
, 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.
|
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.
|
inline |
Whether to handle the deeplinking from the Intent
automatically if the
returns null.
getInitialRoute
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.
|
inline |
Whether state restoration is enabled.
When this returns true, the instance state provided to
will be forwarded to the framework via the
onRestoreInstanceState(Bundle)
and during
RestorationChannelonSaveInstanceState(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.
|
inline |
Definition at line 933 of file FlutterActivity.java.
|
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.
|
inline |
Definition at line 941 of file FlutterActivity.java.
|
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.
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
.
SplashScreenView#remove
Implements io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.
Definition at line 1489 of file FlutterActivity.java.
|
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
.
cachedEngineId | A cached engine ID. |
Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithIntentBuilders.
Definition at line 361 of file FlutterActivity.java.
|
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.
Reimplemented in io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithIntentBuilders.
Definition at line 250 of file FlutterActivity.java.
|
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);
engineGroupId | A cached engine group ID. |
Definition at line 474 of file FlutterActivity.java.
|
protected |
Definition at line 597 of file FlutterActivity.java.
|
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.