public final class FlutterActivityDelegate extends Object implements FlutterActivityEvents, FlutterView.Provider, PluginRegistry
Activity
instances to Flutter.
This exists as a dedicated class (as opposed to being integrated directly
into FlutterActivity
) to facilitate applications that don't wish
to subclass FlutterActivity
. The most obvious example of when this
may come in handy is if an application wishes to subclass the Android v4
support library's FragmentActivity
.
To wire this class up to your activity, simply forward the events defined
in FlutterActivityEvents
from your activity to an instance of this
class. Optionally, you can make your activity implement
PluginRegistry
and/or FlutterView.Provider
and forward those methods to this class as well.
Modifier and Type | Class and Description |
---|---|
static interface |
FlutterActivityDelegate.ViewFactory
Specifies the mechanism by which Flutter views are created during the
operation of a
FlutterActivityDelegate . |
PluginRegistry.ActivityResultListener, PluginRegistry.NewIntentListener, PluginRegistry.PluginRegistrantCallback, PluginRegistry.Registrar, PluginRegistry.RequestPermissionsResultListener, PluginRegistry.UserLeaveHintListener, PluginRegistry.ViewDestroyListener
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
FlutterActivityDelegate(Activity activity,
FlutterActivityDelegate.ViewFactory viewFactory) |
Modifier and Type | Method and Description |
---|---|
FlutterView |
getFlutterView()
Returns a reference to the Flutter view maintained by this object.
|
boolean |
hasPlugin(String key)
Returns whether the specified plugin is known to this registry.
|
boolean |
onActivityResult(int requestCode,
int resultCode,
Intent data) |
boolean |
onBackPressed()
Invoked when the activity has detected the user's press of the back key.
|
void |
onConfigurationChanged(Configuration newConfig) |
void |
onCreate(Bundle savedInstanceState) |
void |
onDestroy() |
void |
onLowMemory() |
void |
onNewIntent(Intent intent) |
void |
onPause() |
void |
onPostResume() |
boolean |
onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults) |
void |
onResume() |
void |
onStart() |
void |
onStop() |
void |
onTrimMemory(int level) |
void |
onUserLeaveHint() |
PluginRegistry.Registrar |
registrarFor(String pluginKey)
Returns a
PluginRegistry.Registrar for receiving the registrations pertaining
to the specified plugin. |
<T> T |
valuePublishedByPlugin(String pluginKey)
Returns the value published by the specified plugin, if any.
|
public FlutterActivityDelegate(Activity activity, FlutterActivityDelegate.ViewFactory viewFactory)
public FlutterView getFlutterView()
FlutterView.Provider
null
.getFlutterView
in interface FlutterView.Provider
public boolean hasPlugin(String key)
PluginRegistry
hasPlugin
in interface PluginRegistry
key
- a unique String identifying the plugin; typically the
fully qualified name of the plugin's main class.public <T> T valuePublishedByPlugin(String pluginKey)
PluginRegistry
Plugins may publish a single value, such as an instance of the plugin's main class, for situations where external control or interaction is needed. Clients are expected to know the value's type.
valuePublishedByPlugin
in interface PluginRegistry
pluginKey
- a unique String identifying the plugin; typically the
fully qualified name of the plugin's main class.public PluginRegistry.Registrar registrarFor(String pluginKey)
PluginRegistry
PluginRegistry.Registrar
for receiving the registrations pertaining
to the specified plugin.registrarFor
in interface PluginRegistry
pluginKey
- a unique String identifying the plugin; typically the
fully qualified name of the plugin's main class.public boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
onRequestPermissionsResult
in interface PluginRegistry.RequestPermissionsResultListener
public boolean onActivityResult(int requestCode, int resultCode, Intent data)
onActivityResult
in interface PluginRegistry.ActivityResultListener
public void onCreate(Bundle savedInstanceState)
onCreate
in interface FlutterActivityEvents
Activity.onCreate(android.os.Bundle)
public void onNewIntent(Intent intent)
onNewIntent
in interface FlutterActivityEvents
Activity.onNewIntent(Intent)
public void onPause()
onPause
in interface FlutterActivityEvents
Activity.onPause()
public void onStart()
onStart
in interface FlutterActivityEvents
Activity.onStart()
public void onResume()
onResume
in interface FlutterActivityEvents
Activity.onResume()
public void onStop()
onStop
in interface FlutterActivityEvents
Activity.onStop()
public void onPostResume()
onPostResume
in interface FlutterActivityEvents
Activity.onPostResume()
public void onDestroy()
onDestroy
in interface FlutterActivityEvents
Activity.onDestroy()
public boolean onBackPressed()
FlutterActivityEvents
onBackPressed
in interface FlutterActivityEvents
true
if the listener handled the event; false
to let the activity continue with its default back button handling.Activity.onBackPressed()
public void onUserLeaveHint()
onUserLeaveHint
in interface FlutterActivityEvents
Activity.onUserLeaveHint()
public void onTrimMemory(int level)
onTrimMemory
in interface ComponentCallbacks2
public void onLowMemory()
onLowMemory
in interface ComponentCallbacks
public void onConfigurationChanged(Configuration newConfig)
onConfigurationChanged
in interface ComponentCallbacks