Interface ActivityAware
FlutterPlugin that is interested in Activity lifecycle events related to a FlutterEngine running within the given Activity.-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidThis plugin has been detached from anActivity.voidTheActivitythat was attached and made available inonAttachedToActivity(ActivityPluginBinding)has been detached from thisActivityAware'sFlutterEnginefor the purpose of processing a configuration change.voidThis plugin and itsFlutterEnginehave been re-attached to anActivityafter theActivitywas recreated to handle configuration changes.
-
Method Details
-
onAttachedToActivity
ThisActivityAwareFlutterPluginis now associated with anActivity.This method can be invoked in 1 of 2 situations:
- This
ActivityAwareFlutterPluginwas just added to aFlutterEnginethat was already connected to a runningActivity. - This
ActivityAwareFlutterPluginwas already added to aFlutterEngineand thatFlutterEnginewas just connected to anActivity.
ActivityPluginBindingcontainsActivity-related references that anActivityAwareFlutterPluginmay require, such as a reference to the actualActivityin question. TheActivityPluginBindingmay 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()TheActivitythat was attached and made available inonAttachedToActivity(ActivityPluginBinding)has been detached from thisActivityAware'sFlutterEnginefor the purpose of processing a configuration change.By the end of this method, the
Activitythat was made available inonAttachedToActivity(ActivityPluginBinding)is no longer valid. Any references to the associatedActivityorActivityPluginBindingshould be cleared.This method should be quickly followed by
onReattachedToActivityForConfigChanges(ActivityPluginBinding), which signifies that a newActivityhas been created with the new configuration options. That method provides a newActivityPluginBinding, which references the newly created and associatedActivity.Any
Lifecyclelisteners that were registered inonAttachedToActivity(ActivityPluginBinding)should be deregistered here to avoid a possible memory leak and other side effects. -
onReattachedToActivityForConfigChanges
This plugin and itsFlutterEnginehave been re-attached to anActivityafter theActivitywas recreated to handle configuration changes.bindingincludes a reference to the new instance of theActivity.bindingand 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
Activityinstance has been destroyed. - The
FlutterEnginethat this plugin is connected to has been detached from itsFlutterView. - This
ActivityAwareplugin has been removed from itsFlutterEngine.
Activitythat was made available inonAttachedToActivity(ActivityPluginBinding)is no longer valid. Any references to the associatedActivityorActivityPluginBindingshould be cleared.Any
Lifecyclelisteners 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
-