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
Activity
is created, and its associatedFlutterEngine
is executing Dart code, theActivity
should invokeattachToActivity(ExclusiveAppComponent, Lifecycle)
. At this point theFlutterEngine
is considered "attached" to theActivity
and allActivityAware
plugins are given access to theActivity
. - Just before an attached
Activity
is destroyed for configuration change purposes, thatActivity
should invokedetachFromActivityForConfigChanges()
, giving eachActivityAware
plugin an opportunity to clean up its references before theis destroyed
. - When an
Activity
is destroyed for non-configuration-change purposes, or when theActivity
is no longer interested in displaying aFlutterEngine
's content, theActivity
should invokedetachFromActivity()
. - When a
Activity
is being attached while an existingExclusiveAppComponent
is already attached, the existingExclusiveAppComponent
is 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 TypeMethodDescriptionvoid
attachToActivity
(ExclusiveAppComponent<Activity> exclusiveActivity, androidx.lifecycle.Lifecycle lifecycle) Call this method from theExclusiveAppComponent
that is displaying the visual content of theFlutterEngine
that is associated with thisActivityControlSurface
.void
Call this method from theActivity
that is attached to thisActivityControlSurfaces
'sFlutterEngine
when theActivity
is about to be destroyed for non-configuration-change reasons.void
Call this method from theActivity
that is attached to thisActivityControlSurfaces
'sFlutterEngine
when theActivity
is about to be destroyed due to configuration changes.boolean
onActivityResult
(int requestCode, int resultCode, Intent data) Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked.void
onNewIntent
(Intent intent) Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked.boolean
onRequestPermissionsResult
(int requestCode, String[] permissions, int[] grantResult) Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked.void
onRestoreInstanceState
(Bundle bundle) Call this method from theActivity
orFragment
that is attached to thisActivityControlSurface
'sFlutterEngine
whenActivity.onCreate(Bundle)
orFragment#onCreate(Bundle)
is invoked in theActivity
orFragment
.void
onSaveInstanceState
(Bundle bundle) Call this method from theActivity
orFragment
that is attached to thisActivityControlSurface
'sFlutterEngine
when the associated method is invoked in theActivity
orFragment
.void
Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked.
-
Method Details
-
attachToActivity
void attachToActivity(@NonNull ExclusiveAppComponent<Activity> exclusiveActivity, @NonNull androidx.lifecycle.Lifecycle lifecycle) Call this method from theExclusiveAppComponent
that is displaying the visual content of theFlutterEngine
that is associated with thisActivityControlSurface
.Once an
ExclusiveAppComponent
is created, and its associatedFlutterEngine
is executing Dart code, theExclusiveAppComponent
should invoke this method. At that point theFlutterEngine
is considered "attached" to theExclusiveAppComponent
and allActivityAware
plugins are given access to theExclusiveAppComponent
'sActivity
. -
detachFromActivityForConfigChanges
void detachFromActivityForConfigChanges()Call this method from theActivity
that is attached to thisActivityControlSurfaces
'sFlutterEngine
when theActivity
is about to be destroyed due to configuration changes.This method gives each
ActivityAware
plugin an opportunity to clean up its references before theis destroyed
. -
detachFromActivity
void detachFromActivity()Call this method from theActivity
that is attached to thisActivityControlSurfaces
'sFlutterEngine
when theActivity
is about to be destroyed for non-configuration-change reasons.This method gives each
ActivityAware
plugin 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 theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked.Returns true if one or more plugins utilized this permission result.
-
onActivityResult
Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked.Returns true if one or more plugins utilized this
Activity
result. -
onNewIntent
Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked. -
onUserLeaveHint
void onUserLeaveHint()Call this method from theActivity
that is attached to thisActivityControlSurface
'sFlutterEngine
and the associated method in theActivity
is invoked. -
onSaveInstanceState
Call this method from theActivity
orFragment
that is attached to thisActivityControlSurface
'sFlutterEngine
when the associated method is invoked in theActivity
orFragment
. -
onRestoreInstanceState
Call this method from theActivity
orFragment
that is attached to thisActivityControlSurface
'sFlutterEngine
whenActivity.onCreate(Bundle)
orFragment#onCreate(Bundle)
is invoked in theActivity
orFragment
.
-