Interface ActivityControlSurface
Activity attaches to a FlutterEngine.
An Activity that contains a FlutterView and associated FlutterEngine should coordinate itself with the FlutterEngine's ActivityControlSurface.
- Once an
Activityis created, and its associatedFlutterEngineis executing Dart code, theActivityshould invokeattachToActivity(ExclusiveAppComponent, Lifecycle). At this point theFlutterEngineis considered "attached" to theActivityand allActivityAwareplugins are given access to theActivity. - Just before an attached
Activityis destroyed for configuration change purposes, thatActivityshould invokedetachFromActivityForConfigChanges(), giving eachActivityAwareplugin an opportunity to clean up its references before theis destroyed. - When an
Activityis destroyed for non-configuration-change purposes, or when theActivityis no longer interested in displaying aFlutterEngine's content, theActivityshould invokedetachFromActivity(). - When a
Activityis being attached while an existingExclusiveAppComponentis already attached, the existingExclusiveAppComponentis given a chance to detach first viaExclusiveAppComponent.detachFromFlutterEngine()before the new activity attaches.
Activity should also forward all Activity
calls that this ActivityControlSurface supports, e.g., onRequestPermissionsResult(int, String[], int[]). These forwarded calls are made available to
all ActivityAware plugins that are added to the attached FlutterEngine.-
Method Summary
Modifier and TypeMethodDescriptionvoidattachToActivity(ExclusiveAppComponent<Activity> exclusiveActivity, androidx.lifecycle.Lifecycle lifecycle) Call this method from theExclusiveAppComponentthat is displaying the visual content of theFlutterEnginethat is associated with thisActivityControlSurface.voidCall this method from theActivitythat is attached to thisActivityControlSurfaces'sFlutterEnginewhen theActivityis about to be destroyed for non-configuration-change reasons.voidCall this method from theActivitythat is attached to thisActivityControlSurfaces'sFlutterEnginewhen theActivityis about to be destroyed due to configuration changes.booleanonActivityResult(int requestCode, int resultCode, Intent data) Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked.voidonNewIntent(Intent intent) Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked.booleanonRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResult) Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked.voidonRestoreInstanceState(Bundle bundle) Call this method from theActivityorFragmentthat is attached to thisActivityControlSurface'sFlutterEnginewhenActivity.onCreate(Bundle)orFragment#onCreate(Bundle)is invoked in theActivityorFragment.voidonSaveInstanceState(Bundle bundle) Call this method from theActivityorFragmentthat is attached to thisActivityControlSurface'sFlutterEnginewhen the associated method is invoked in theActivityorFragment.voidCall this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked.
-
Method Details
-
attachToActivity
void attachToActivity(@NonNull ExclusiveAppComponent<Activity> exclusiveActivity, @NonNull androidx.lifecycle.Lifecycle lifecycle) Call this method from theExclusiveAppComponentthat is displaying the visual content of theFlutterEnginethat is associated with thisActivityControlSurface.Once an
ExclusiveAppComponentis created, and its associatedFlutterEngineis executing Dart code, theExclusiveAppComponentshould invoke this method. At that point theFlutterEngineis considered "attached" to theExclusiveAppComponentand allActivityAwareplugins are given access to theExclusiveAppComponent'sActivity. -
detachFromActivityForConfigChanges
void detachFromActivityForConfigChanges()Call this method from theActivitythat is attached to thisActivityControlSurfaces'sFlutterEnginewhen theActivityis about to be destroyed due to configuration changes.This method gives each
ActivityAwareplugin an opportunity to clean up its references before theis destroyed. -
detachFromActivity
void detachFromActivity()Call this method from theActivitythat is attached to thisActivityControlSurfaces'sFlutterEnginewhen theActivityis about to be destroyed for non-configuration-change reasons.This method gives each
ActivityAwareplugin an opportunity to clean up its references before theis destroyed. -
onRequestPermissionsResult
boolean onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResult) Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked.Returns true if one or more plugins utilized this permission result.
-
onActivityResult
Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked.Returns true if one or more plugins utilized this
Activityresult. -
onNewIntent
Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked. -
onUserLeaveHint
void onUserLeaveHint()Call this method from theActivitythat is attached to thisActivityControlSurface'sFlutterEngineand the associated method in theActivityis invoked. -
onSaveInstanceState
Call this method from theActivityorFragmentthat is attached to thisActivityControlSurface'sFlutterEnginewhen the associated method is invoked in theActivityorFragment. -
onRestoreInstanceState
Call this method from theActivityorFragmentthat is attached to thisActivityControlSurface'sFlutterEnginewhenActivity.onCreate(Bundle)orFragment#onCreate(Bundle)is invoked in theActivityorFragment.
-