public interface ActivityAware
FlutterPlugin
that is interested in Activity
lifecycle events related to a
FlutterEngine
running within the given Activity
.Modifier and Type | Method and Description |
---|---|
void |
onAttachedToActivity(ActivityPluginBinding binding)
This
ActivityAware FlutterPlugin is now associated with an Activity . |
void |
onDetachedFromActivity()
This plugin has been detached from an
Activity . |
void |
onDetachedFromActivityForConfigChanges()
The
Activity that was attached and made available in
onAttachedToActivity(ActivityPluginBinding) has been detached from this
ActivityAware 's FlutterEngine for the purpose of processing a configuration
change. |
void |
onReattachedToActivityForConfigChanges(ActivityPluginBinding binding)
This plugin and its
FlutterEngine have been re-attached to an Activity after
the Activity was recreated to handle configuration changes. |
void onAttachedToActivity(@NonNull ActivityPluginBinding binding)
ActivityAware
FlutterPlugin
is now associated with an Activity
.
This method can be invoked in 1 of 2 situations:
ActivityAware
FlutterPlugin
was just added to a FlutterEngine
that was already connected to a running Activity
.ActivityAware
FlutterPlugin
was already added to a
FlutterEngine
and that FlutterEngine
was just connected to an
Activity
.ActivityPluginBinding
contains Activity
-related references that an
ActivityAware
FlutterPlugin
may require, such as a reference to the actual
Activity
in question. The ActivityPluginBinding
may be referenced until either
onDetachedFromActivityForConfigChanges()
or onDetachedFromActivity()
is
invoked. At the conclusion of either of those methods, the binding is no longer valid. Clear
any references to the binding or its resources, and do not invoke any further methods on the
binding or its resources.void onDetachedFromActivityForConfigChanges()
Activity
that was attached and made available in
onAttachedToActivity(ActivityPluginBinding)
has been detached from this
ActivityAware
's FlutterEngine
for the purpose of processing a configuration
change.
By the end of this method, the Activity
that was made available in
onAttachedToActivity(ActivityPluginBinding)
is no longer valid. Any references to the
associated Activity
or ActivityPluginBinding
should be cleared.
This method should be quickly followed by
onReattachedToActivityForConfigChanges(ActivityPluginBinding)
, which signifies that a
new Activity
has been created with the new configuration options. That method provides
a new ActivityPluginBinding
, which references the newly created and associated
Activity
.
Any Lifecycle
listeners that were registered in
onAttachedToActivity(ActivityPluginBinding)
should be deregistered here to avoid a
possible memory leak and other side effects.
void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding)
FlutterEngine
have been re-attached to an Activity
after
the Activity
was recreated to handle configuration changes.
binding
includes a reference to the new instance of the Activity
. binding
and its references may be cached and used from now until either
onDetachedFromActivityForConfigChanges()
or onDetachedFromActivity()
is
invoked. At the conclusion of either of those methods, the binding is no longer valid. Clear
any references to the binding or its resources, and do not invoke any further methods on the
binding or its resources.
void onDetachedFromActivity()
Activity
.
Detachment can occur for a number of reasons.
Activity
instance has been destroyed.FlutterEngine
that this plugin is connected to has been detached from
its FlutterView
.ActivityAware
plugin has been removed from its FlutterEngine
.Activity
that was made available in
onAttachedToActivity(ActivityPluginBinding)
is no longer valid. Any references to the
associated Activity
or ActivityPluginBinding
should be cleared.
Any Lifecycle
listeners that were registered in
onAttachedToActivity(ActivityPluginBinding)
or
onReattachedToActivityForConfigChanges(ActivityPluginBinding)
should be deregistered
here to avoid a possible memory leak and other side effects.