open_file icon indicating copy to clipboard operation
open_file copied to clipboard

Fix for OpenFilePlugin

Open c2call opened this issue 3 years ago • 2 comments

Hi, the OpenFilePlugin code has issues and causes problems in an Add-to-App scenario when FlutterActivity will be opened, then closed and re-opened again. This causes an exception in onAttachedToActivity during plugin initialization. The problem is creating the MethodChannel here is the wrong place as the global variable flutterPluginBinding is still null (the order of calling onAttachToEngine and onAttachedToActivity seams to change after launching FlutterActivity a second time).

I've done the following fix in my local code:

// Moved MethodChannel creation into onAttachedToEngine public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { this.flutterPluginBinding = binding; channel = new MethodChannel( binding.getBinaryMessenger(), "open_file"); channel.setMethodCallHandler(this); context = binding.getApplicationContext(); }

public void onAttachedToActivity(ActivityPluginBinding binding) {
    activity = binding.getActivity();
    binding.addRequestPermissionsResultListener(this);
    binding.addActivityResultListener(this);
}

Please add the changes to to your code. Thanks

c2call avatar Sep 12 '21 07:09 c2call

any update on the package!?!

P-B1101 avatar Feb 23 '22 06:02 P-B1101

A fix has been made at open_filex 4.3.2

javaherisaber avatar Dec 08 '22 15:12 javaherisaber