Interface ActivityAware
-
public interface ActivityAware
FlutterPlugin
that is interested inActivity
lifecycle events related to aFlutterEngine
running within the givenActivity
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onAttachedToActivity(ActivityPluginBinding binding)
void
onDetachedFromActivity()
This plugin has been detached from anActivity
.void
onDetachedFromActivityForConfigChanges()
TheActivity
that was attached and made available inonAttachedToActivity(ActivityPluginBinding)
has been detached from thisActivityAware
'sFlutterEngine
for the purpose of processing a configuration change.void
onReattachedToActivityForConfigChanges(ActivityPluginBinding binding)
This plugin and itsFlutterEngine
have been re-attached to anActivity
after theActivity
was recreated to handle configuration changes.
-
-
-
Method Detail
-
onAttachedToActivity
void onAttachedToActivity(@NonNull ActivityPluginBinding binding)
ThisActivityAware
FlutterPlugin
is now associated with anActivity
.This method can be invoked in 1 of 2 situations:
- This
ActivityAware
FlutterPlugin
was just added to aFlutterEngine
that was already connected to a runningActivity
. - This
ActivityAware
FlutterPlugin
was already added to aFlutterEngine
and thatFlutterEngine
was just connected to anActivity
.
ActivityPluginBinding
containsActivity
-related references that anActivityAware
FlutterPlugin
may require, such as a reference to the actualActivity
in question. TheActivityPluginBinding
may be referenced until eitheronDetachedFromActivityForConfigChanges()
oronDetachedFromActivity()
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. - This
-
onDetachedFromActivityForConfigChanges
void onDetachedFromActivityForConfigChanges()
TheActivity
that was attached and made available inonAttachedToActivity(ActivityPluginBinding)
has been detached from thisActivityAware
'sFlutterEngine
for the purpose of processing a configuration change.By the end of this method, the
Activity
that was made available inonAttachedToActivity(ActivityPluginBinding)
is no longer valid. Any references to the associatedActivity
orActivityPluginBinding
should be cleared.This method should be quickly followed by
onReattachedToActivityForConfigChanges(ActivityPluginBinding)
, which signifies that a newActivity
has been created with the new configuration options. That method provides a newActivityPluginBinding
, which references the newly created and associatedActivity
.Any
Lifecycle
listeners that were registered inonAttachedToActivity(ActivityPluginBinding)
should be deregistered here to avoid a possible memory leak and other side effects.
-
onReattachedToActivityForConfigChanges
void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding)
This plugin and itsFlutterEngine
have been re-attached to anActivity
after theActivity
was recreated to handle configuration changes.binding
includes a reference to the new instance of theActivity
.binding
and its references may be cached and used from now until eitheronDetachedFromActivityForConfigChanges()
oronDetachedFromActivity()
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.
-
onDetachedFromActivity
void onDetachedFromActivity()
This plugin has been detached from anActivity
.Detachment can occur for a number of reasons.
- The app is no longer visible and the
Activity
instance has been destroyed. - The
FlutterEngine
that this plugin is connected to has been detached from itsFlutterView
. - This
ActivityAware
plugin has been removed from itsFlutterEngine
.
Activity
that was made available inonAttachedToActivity(ActivityPluginBinding)
is no longer valid. Any references to the associatedActivity
orActivityPluginBinding
should be cleared.Any
Lifecycle
listeners that were registered inonAttachedToActivity(ActivityPluginBinding)
oronReattachedToActivityForConfigChanges(ActivityPluginBinding)
should be deregistered here to avoid a possible memory leak and other side effects. - The app is no longer visible and the
-
-