Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host Interface Reference
Inheritance diagram for io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host:
io.flutter.embedding.android.FlutterEngineProvider io.flutter.embedding.android.FlutterEngineConfigurator io.flutter.plugin.platform.PlatformPlugin.PlatformPluginDelegate io.flutter.embedding.android.FlutterActivity io.flutter.embedding.android.FlutterFragment dev.flutter.scenarios.TestableFlutterActivity io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithIntentBuilders io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithProvidedEngine dev.flutter.scenarios.TestActivity dev.flutter.scenarios.ExternalTextureFlutterActivity dev.flutter.scenarios.GetBitmapActivity dev.flutter.scenarios.PlatformViewsActivity dev.flutter.scenarios.SpawnMultiEngineActivity dev.flutter.scenarios.SpawnedEngineActivity

Public Member Functions

Context getContext ()
 
boolean shouldHandleDeeplinking ()
 
Activity getActivity ()
 
Lifecycle getLifecycle ()
 
FlutterShellArgs getFlutterShellArgs ()
 
String getCachedEngineId ()
 
String getCachedEngineGroupId ()
 
boolean shouldDestroyEngineWithHost ()
 
void detachFromFlutterEngine ()
 
String getDartEntrypointFunctionName ()
 
String getDartEntrypointLibraryUri ()
 
List< String > getDartEntrypointArgs ()
 
String getAppBundlePath ()
 
String getInitialRoute ()
 
RenderMode getRenderMode ()
 
TransparencyMode getTransparencyMode ()
 
ExclusiveAppComponent< Activity > getExclusiveAppComponent ()
 
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 ()
 
void onFlutterSurfaceViewCreated (@NonNull FlutterSurfaceView flutterSurfaceView)
 
void onFlutterTextureViewCreated (@NonNull FlutterTextureView flutterTextureView)
 
void onFlutterUiDisplayed ()
 
void onFlutterUiNoLongerDisplayed ()
 
boolean shouldRestoreAndSaveState ()
 
void updateSystemUiOverlays ()
 
boolean shouldDispatchAppLifecycleState ()
 
boolean attachToEngineAutomatically ()
 
FlutterEngine provideFlutterEngine (@NonNull Context context)
 
void configureFlutterEngine (@NonNull FlutterEngine flutterEngine)
 
void cleanUpFlutterEngine (@NonNull FlutterEngine flutterEngine)
 
- Public Member Functions inherited from io.flutter.plugin.platform.PlatformPlugin.PlatformPluginDelegate
boolean popSystemNavigator ()
 
default void setFrameworkHandlesBack (boolean frameworkHandlesBack)
 

Detailed Description

The FlutterActivity or FlutterFragment that owns this
FlutterActivityAndFragmentDelegate
.

Definition at line 1051 of file FlutterActivityAndFragmentDelegate.java.

Member Function Documentation

◆ attachToEngineAutomatically()

boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.attachToEngineAutomatically ( )

Whether to automatically attach the FlutterView to the engine.

In the add-to-app scenario where multiple FlutterView share the same FlutterEngine, the host application desires to determine the timing of attaching the FlutterView to the engine, for example, during the onResume instead of the
onCreateView
.

Defaults to true.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ cleanUpFlutterEngine()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.cleanUpFlutterEngine ( @NonNull FlutterEngine  flutterEngine)

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

Implements io.flutter.embedding.android.FlutterEngineConfigurator.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ configureFlutterEngine()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.configureFlutterEngine ( @NonNull FlutterEngine  flutterEngine)

◆ detachFromFlutterEngine()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.detachFromFlutterEngine ( )

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.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getActivity()

Activity io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getActivity ( )

Returns the host android.app.Activity or the Activity that is currently attached to the host Fragment.

Implemented in io.flutter.embedding.android.FlutterActivity.

◆ getAppBundlePath()

String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getAppBundlePath ( )

Returns the path to the app bundle where the Dart code exists.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getCachedEngineGroupId()

String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getCachedEngineGroupId ( )

◆ getCachedEngineId()

String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getCachedEngineId ( )

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

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getContext()

Context io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getContext ( )

Returns the Context that backs the host android.app.Activity or
Fragment
.

Implemented in io.flutter.embedding.android.FlutterActivity.

◆ getDartEntrypointArgs()

List< String > io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getDartEntrypointArgs ( )

Returns arguments that passed as a list of string to Dart's entrypoint function.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getDartEntrypointFunctionName()

String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getDartEntrypointFunctionName ( )

Returns the Dart entrypoint that should run when a new io.flutter.embedding.engine.FlutterEngine is created.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getDartEntrypointLibraryUri()

String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getDartEntrypointLibraryUri ( )

Returns the URI of the Dart library which contains the entrypoint method (example "package:foo_package/main.dart"). If null, this will default to the same library as the main() function in the Dart program.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getExclusiveAppComponent()

ExclusiveAppComponent< Activity > io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getExclusiveAppComponent ( )

Returns the ExclusiveAppComponent<Activity> that is associated with io.flutter.embedding.engine.FlutterEngine.

In the scenario where multiple FlutterActivity or FlutterFragment share the same FlutterEngine, to attach/re-attache a FlutterActivity or FlutterFragment to the shared FlutterEngine, we MUST manually invoke ActivityControlSurface#attachToActivity(ExclusiveAppComponent, Lifecycle).

The ExclusiveAppComponent is exposed here so that subclasses of FlutterActivity or FlutterFragment can access it.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getFlutterShellArgs()

FlutterShellArgs io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getFlutterShellArgs ( )

◆ getInitialRoute()

String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getInitialRoute ( )

Returns the initial route that Flutter renders.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ getLifecycle()

Lifecycle io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getLifecycle ( )

Returns the Lifecycle that backs the host android.app.Activity or
Fragment
.

Implemented in io.flutter.embedding.android.FlutterActivity.

◆ getRenderMode()

RenderMode io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getRenderMode ( )

◆ getTransparencyMode()

TransparencyMode io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getTransparencyMode ( )

◆ onFlutterSurfaceViewCreated()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterSurfaceViewCreated ( @NonNull FlutterSurfaceView  flutterSurfaceView)

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.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ onFlutterTextureViewCreated()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterTextureViewCreated ( @NonNull FlutterTextureView  flutterTextureView)

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.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ onFlutterUiDisplayed()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterUiDisplayed ( )

◆ onFlutterUiNoLongerDisplayed()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterUiNoLongerDisplayed ( )

Invoked by this delegate when its FlutterView stops painting pixels.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ provideFlutterEngine()

FlutterEngine io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.provideFlutterEngine ( @NonNull Context  context)

◆ providePlatformPlugin()

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

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

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ shouldAttachEngineToActivity()

boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldAttachEngineToActivity ( )

Returns true if the io.flutter.embedding.engine.FlutterEngine's plugin system should be connected to the host android.app.Activity, allowing plugins to interact with it.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ shouldDestroyEngineWithHost()

boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldDestroyEngineWithHost ( )

Returns true if the io.flutter.embedding.engine.FlutterEngine used in this delegate should be destroyed when the host/delegate are destroyed.

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

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ shouldDispatchAppLifecycleState()

boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldDispatchAppLifecycleState ( )

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

In the add-to-app scenario where multiple FlutterActivity shares the same FlutterEngine, the application lifecycle state will have crosstalk causing the page to freeze. For example, we open a new page called FlutterActivity#2 from the previous page called FlutterActivity#1. The flow of app lifecycle states received by dart is as follows:

inactive (from FlutterActivity#1) -> resumed (from FlutterActivity#2) -> paused (from FlutterActivity#1)

On the one hand, the paused state from FlutterActivity#1 will cause the FlutterActivity#2 page to be stuck; On the other hand, these states are not expected from the perspective of the entire application lifecycle. If the host application gets the control of sending AppLifecycleState, It will be possible to correctly match the AppLifecycleState with the application-level lifecycle.

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

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ shouldHandleDeeplinking()

boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldHandleDeeplinking ( )

Returns true if the delegate should retrieve the initial route from the Intent.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ shouldRestoreAndSaveState()

boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldRestoreAndSaveState ( )

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.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.

◆ updateSystemUiOverlays()

void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.updateSystemUiOverlays ( )

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
.

Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.


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