Skip to content

Commit

Permalink
make plugin work in headless mode when extending FlutterApplication (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
masewo authored and charafau committed Nov 14, 2019
1 parent abbb4db commit 8fa0d60
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ public class FlutterWebviewPlugin implements MethodCallHandler, PluginRegistry.A
private static final String JS_CHANNEL_NAMES_FIELD = "javascriptChannelNames";

public static void registerWith(PluginRegistry.Registrar registrar) {
channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
final FlutterWebviewPlugin instance = new FlutterWebviewPlugin(registrar.activity(), registrar.activeContext());
registrar.addActivityResultListener(instance);
channel.setMethodCallHandler(instance);
if (registrar.activity() != null) {
channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
final FlutterWebviewPlugin instance = new FlutterWebviewPlugin(registrar.activity(), registrar.activeContext());
registrar.addActivityResultListener(instance);
channel.setMethodCallHandler(instance);
}
}

FlutterWebviewPlugin(Activity activity, Context context) {
Expand Down

0 comments on commit 8fa0d60

Please sign in to comment.