diff --git a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java index d03a5d76..614901fc 100644 --- a/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java +++ b/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java @@ -23,7 +23,6 @@ import io.flutter.plugin.common.EventChannel; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; -import io.flutter.plugin.common.PluginRegistry; /** * FilePickerPlugin @@ -116,29 +115,6 @@ public void onActivityStopped(final Activity activity) { private static boolean withData = false; private static int compressionQuality; - /** - * Plugin registration. - */ - public static void registerWith(final io.flutter.plugin.common.PluginRegistry.Registrar registrar) { - - if (registrar.activity() == null) { - // If a background flutter view tries to register the plugin, there will be no activity from the registrar, - // we stop the registering process immediately because the ImagePicker requires an activity. - return; - } - - final Activity activity = registrar.activity(); - Application application = null; - if (registrar.context() != null) { - application = (Application) (registrar.context().getApplicationContext()); - } - - final FilePickerPlugin plugin = new FilePickerPlugin(); - plugin.setup(registrar.messenger(), application, activity, registrar, null); - - } - - @SuppressWarnings("unchecked") @Override public void onMethodCall(final MethodCall call, final MethodChannel.Result rawResult) { @@ -258,7 +234,6 @@ private void setup( final BinaryMessenger messenger, final Application application, final Activity activity, - final PluginRegistry.Registrar registrar, final ActivityPluginBinding activityBinding) { this.activity = activity; @@ -278,18 +253,11 @@ public void onCancel(final Object arguments) { } }); this.observer = new LifeCycleObserver(activity); - if (registrar != null) { - // V1 embedding setup for activity listeners. - application.registerActivityLifecycleCallbacks(this.observer); - registrar.addActivityResultListener(this.delegate); - registrar.addRequestPermissionsResultListener(this.delegate); - } else { - // V2 embedding setup for activity listeners. - activityBinding.addActivityResultListener(this.delegate); - activityBinding.addRequestPermissionsResultListener(this.delegate); - this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); - this.lifecycle.addObserver(this.observer); - } + // V2 embedding setup for activity listeners. + activityBinding.addActivityResultListener(this.delegate); + activityBinding.addRequestPermissionsResultListener(this.delegate); + this.lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding); + this.lifecycle.addObserver(this.observer); } private void tearDown() { @@ -325,7 +293,6 @@ public void onAttachedToActivity(final ActivityPluginBinding binding) { this.pluginBinding.getBinaryMessenger(), (Application) this.pluginBinding.getApplicationContext(), this.activityBinding.getActivity(), - null, this.activityBinding); }