Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
io.flutter.plugin.common.PluginRegistry.Registrar Interface Reference

Public Member Functions

Activity activity ()
 
Context context ()
 
Context activeContext ()
 
BinaryMessenger messenger ()
 
TextureRegistry textures ()
 
PlatformViewRegistry platformViewRegistry ()
 
FlutterView view ()
 
String lookupKeyForAsset (@NonNull String asset)
 
String lookupKeyForAsset (@NonNull String asset, @NonNull String packageName)
 
Registrar publish (@Nullable Object value)
 
Registrar addRequestPermissionsResultListener ( @NonNull RequestPermissionsResultListener listener)
 
Registrar addActivityResultListener (@NonNull ActivityResultListener listener)
 
Registrar addNewIntentListener (@NonNull NewIntentListener listener)
 
Registrar addUserLeaveHintListener (@NonNull UserLeaveHintListener listener)
 
Registrar addWindowFocusChangedListener (@NonNull WindowFocusChangedListener listener)
 
Registrar addViewDestroyListener (@NonNull ViewDestroyListener listener)
 

Detailed Description

Receiver of registrations from a single plugin.

Deprecated:
This registrar is for Flutter's v1 embedding. For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Definition at line 80 of file PluginRegistry.java.

Member Function Documentation

◆ activeContext()

Context io.flutter.plugin.common.PluginRegistry.Registrar.activeContext ( )

Returns the active Context.

This registrar is for Flutter's v1 embedding. In the v2 embedding, there is no concept of an "active context". Either use the application Context or an attached
Activity
. See context() and activity() for more details.

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Returns
the current Activity, if not null, otherwise the Application.

◆ activity()

Activity io.flutter.plugin.common.PluginRegistry.Registrar.activity ( )

Returns the android.app.Activity that forms the plugin's operating context.

Plugin authors should not assume the type returned by this method is any specific subclass of Activity (such as io.flutter.app.FlutterActivity or io.flutter.app.FlutterFragmentActivity), as applications are free to use any activity subclass.

When there is no foreground activity in the application, this will return null. If a Context is needed, use context() to get the application's context.

This registrar is for Flutter's v1 embedding. To access an Activity from a plugin using the v2 embedding, see ActivityPluginBinding#getActivity(). To obtain an instance of an ActivityPluginBinding in a Flutter plugin, implement the ActivityAware interface. A binding is provided in ActivityAware#onAttachedToActivity(ActivityPluginBinding) and ActivityAware#onReattachedToActivityForConfigChanges(ActivityPluginBinding).

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

◆ addActivityResultListener()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.addActivityResultListener ( @NonNull ActivityResultListener  listener)

Adds a callback allowing the plugin to take part in handling incoming calls to Activity#onActivityResult(int, int, Intent).

This registrar is for Flutter's v1 embedding. To listen for Activity results in the v2 embedding, use ActivityPluginBinding#addActivityResultListener(PluginRegistry.ActivityResultListener).

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
listeneran ActivityResultListener callback.
Returns
this Registrar.

◆ addNewIntentListener()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.addNewIntentListener ( @NonNull NewIntentListener  listener)

Adds a callback allowing the plugin to take part in handling incoming calls to Activity#onNewIntent(Intent).

This registrar is for Flutter's v1 embedding. To listen for new Intents in the v2 embedding, use ActivityPluginBinding#addOnNewIntentListener(PluginRegistry.NewIntentListener).

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
listenera NewIntentListener callback.
Returns
this Registrar.

◆ addRequestPermissionsResultListener()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.addRequestPermissionsResultListener ( @NonNull RequestPermissionsResultListener  listener)

Adds a callback allowing the plugin to take part in handling incoming calls to
Activity#onRequestPermissionsResult(int, String[], int[])
or
androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(int,
String[], int[])
.

This registrar is for Flutter's v1 embedding. To listen for permission results in the v2 embedding, use ActivityPluginBinding#addRequestPermissionsResultListener(PluginRegistry.RequestPermissionsResultListener).

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
listenera RequestPermissionsResultListener callback.
Returns
this Registrar.

◆ addUserLeaveHintListener()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.addUserLeaveHintListener ( @NonNull UserLeaveHintListener  listener)

Adds a callback allowing the plugin to take part in handling incoming calls to Activity#onUserLeaveHint().

This registrar is for Flutter's v1 embedding. To listen for leave hints in the v2 embedding, use ActivityPluginBinding#addOnUserLeaveHintListener(PluginRegistry.UserLeaveHintListener).

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
listenera UserLeaveHintListener callback.
Returns
this Registrar.

◆ addViewDestroyListener()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.addViewDestroyListener ( @NonNull ViewDestroyListener  listener)

Adds a callback allowing the plugin to take part in handling incoming calls to Activity#onDestroy().

This registrar is for Flutter's v1 embedding. The concept of View destruction does not exist in the v2 embedding. However, plugins in the v2 embedding can respond to ActivityAware#onDetachedFromActivityForConfigChanges() and ActivityAware#onDetachedFromActivity(), which indicate the loss of a visual context for the running Flutter experience. Developers should implement ActivityAware for their FlutterPlugin if such callbacks are needed. Also, plugins can respond to FlutterPlugin#onDetachedFromEngine(FlutterPlugin.FlutterPluginBinding), which indicates that the given plugin has been completely disconnected from the associated Flutter experience and should clean up any resources.

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
listenera ViewDestroyListener callback.
Returns
this Registrar.

◆ addWindowFocusChangedListener()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.addWindowFocusChangedListener ( @NonNull WindowFocusChangedListener  listener)

Adds a callback allowing the plugin to take part in handling incoming calls to Activity#onWindowFocusChanged(boolean).

This registrar is for Flutter's v1 embedding. To listen for leave hints in the v2 embedding, use ActivityPluginBinding#addOnWindowFocusChangedListener(PluginRegistry.WindowFocusChangedListener).

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
listenera WindowFocusChangedListener callback.
Returns
this Registrar.

◆ context()

Context io.flutter.plugin.common.PluginRegistry.Registrar.context ( )

Returns the android.app.Application's Context.

This registrar is for Flutter's v1 embedding. To access a Context from a plugin using the v2 embedding, see FlutterPlugin.FlutterPluginBinding#getApplicationContext()

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

◆ lookupKeyForAsset() [1/2]

String io.flutter.plugin.common.PluginRegistry.Registrar.lookupKeyForAsset ( @NonNull String  asset)

Returns the file name for the given asset. The returned file name can be used to access the asset in the APK through the android.content.res.AssetManager API.

TODO(mattcarroll): point this method towards new lookup method.

Parameters
assetthe name of the asset. The name can be hierarchical
Returns
the filename to be used with android.content.res.AssetManager

◆ lookupKeyForAsset() [2/2]

String io.flutter.plugin.common.PluginRegistry.Registrar.lookupKeyForAsset ( @NonNull String  asset,
@NonNull String  packageName 
)

Returns the file name for the given asset which originates from the specified packageName. The returned file name can be used to access the asset in the APK through the android.content.res.AssetManager API.

TODO(mattcarroll): point this method towards new lookup method.

Parameters
assetthe name of the asset. The name can be hierarchical
packageNamethe name of the package from which the asset originates
Returns
the file name to be used with android.content.res.AssetManager

◆ messenger()

BinaryMessenger io.flutter.plugin.common.PluginRegistry.Registrar.messenger ( )

Returns a BinaryMessenger which the plugin can use for creating channels for communicating with the Dart side.

This registrar is for Flutter's v1 embedding. To access a BinaryMessenger from a plugin using the v2 embedding, see FlutterPlugin.FlutterPluginBinding#getBinaryMessenger()

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

◆ platformViewRegistry()

PlatformViewRegistry io.flutter.plugin.common.PluginRegistry.Registrar.platformViewRegistry ( )

Returns the application's PlatformViewRegistry.

Plugins can use the platform registry to register their view factories.

This registrar is for Flutter's v1 embedding. To access a PlatformViewRegistry from a plugin using the v2 embedding, see FlutterPlugin.FlutterPluginBinding#getPlatformViewRegistry()

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

◆ publish()

Registrar io.flutter.plugin.common.PluginRegistry.Registrar.publish ( @Nullable Object  value)

Publishes a value associated with the plugin being registered.

The published value is available to interested clients via PluginRegistry#valuePublishedByPlugin(String).

Publication should be done only when client code needs to interact with the plugin in a way that cannot be accomplished by the plugin registering callbacks with client APIs.

Overwrites any previously published value.

This registrar is for Flutter's v1 embedding. The concept of publishing values from plugins is not supported in the v2 embedding.

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

Parameters
valuethe value, possibly null.
Returns
this Registrar.

◆ textures()

TextureRegistry io.flutter.plugin.common.PluginRegistry.Registrar.textures ( )

Returns a TextureRegistry which the plugin can use for managing backend textures.

This registrar is for Flutter's v1 embedding. To access a TextureRegistry from a plugin using the v2 embedding, see FlutterPlugin.FlutterPluginBinding#getTextureRegistry()

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration

◆ view()

FlutterView io.flutter.plugin.common.PluginRegistry.Registrar.view ( )

Returns the FlutterView that's instantiated by this plugin's activity.

This registrar is for Flutter's v1 embedding. The FlutterView referenced by this method does not exist in the v2 embedding. Additionally, no View is exposed to any plugins in the v2 embedding. Platform views can access their containing View using the platform views APIs. If you have a use-case that absolutely requires a plugin to access an Android View, please file a ticket on GitHub.

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit http://flutter.dev/go/android-plugin-migration


The documentation for this interface was generated from the following file: