io.flutter.plugin.common.BinaryMessenger Java Examples

The following examples show how to use io.flutter.plugin.common.BinaryMessenger. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterFlipperkitPlugin.java    From flutter_flipperkit with MIT License 6 votes vote down vote up
private void setupChannel(BinaryMessenger messenger, Context context) {
    this.context = context;
    SoLoader.init(context.getApplicationContext(), false);
    if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(context)) {
        flipperClient = AndroidFlipperClient.getInstance(context);
        networkFlipperPlugin = new NetworkFlipperPlugin();
        sharedPreferencesFlipperPlugin = new SharedPreferencesFlipperPlugin(context, "FlutterSharedPreferences");

        flipperDatabaseBrowserPlugin = new FlipperDatabaseBrowserPlugin();
        flipperReduxInspectorPlugin = new FlipperReduxInspectorPlugin();
    }

    this.channel = new MethodChannel(messenger, CHANNEL_NAME);
    this.channel.setMethodCallHandler(this);

    this.eventChannel = new EventChannel(messenger, EVENT_CHANNEL_NAME);
    this.eventChannel.setStreamHandler(this);
}
 
Example #2
Source File: FlutterMobileVisionPlugin.java    From flutter_mobile_vision with MIT License 6 votes vote down vote up
private void setup(
        final BinaryMessenger messenger,

        final Activity activity,
        final PluginRegistry.Registrar registrar,
        final ActivityPluginBinding activityBinding) {
    this.activity = activity;
    this.delegate = new FlutterMobileVisionDelegate(activity);
    channel = new MethodChannel(messenger, CHANNEL);
    channel.setMethodCallHandler(this);
    if (registrar != null) {
        // V1 embedding setup for activity listeners.
        registrar.addActivityResultListener(delegate);
        registrar.addRequestPermissionsResultListener(delegate);
    } else {
        // V2 embedding setup for activity listeners.
        activityBinding.addActivityResultListener(delegate);
        activityBinding.addRequestPermissionsResultListener(delegate);
    }
}
 
Example #3
Source File: StreamsChannel.java    From streams_channel with Apache License 2.0 6 votes vote down vote up
public StreamsChannel(BinaryMessenger messenger, String name, MethodCodec codec) {
  if (BuildConfig.DEBUG) {
    if (messenger == null) {
      Log.e(TAG, "Parameter messenger must not be null.");
    }
    if (name == null) {
      Log.e(TAG, "Parameter name must not be null.");
    }
    if (codec == null) {
      Log.e(TAG, "Parameter codec must not be null.");
    }
  }
  this.messenger = messenger;
  this.name = name;
  this.codec = codec;
}
 
Example #4
Source File: QrMobileVisionPlugin.java    From flutter_qr_mobile_vision with MIT License 6 votes vote down vote up
private void performRegistration(boolean isVersion1Embedding, Registrar registrar, FlutterPluginBinding flutterPluginBinding, ActivityPluginBinding activityPluginBinding) {
    Log.i(TAG, "Plugin Registration being performed: " +
        "isVersion1Embedding " + isVersion1Embedding +
        ", registrar " + registrar +
        ", flutterPluginBinding " + flutterPluginBinding +
        ", activityPluginBinding " + activityPluginBinding);

    BinaryMessenger messenger;
    if (isVersion1Embedding) {
        messenger = registrar.messenger();
        activity = registrar.activity();
        textures = registrar.textures();
        registrar.addRequestPermissionsResultListener(this);
    } else {
        messenger = flutterPluginBinding.getBinaryMessenger();
        activity = activityPluginBinding.getActivity();
        textures = flutterPluginBinding.getTextureRegistry();
        activityPluginBinding.addRequestPermissionsResultListener(this);
    }
    channel = new MethodChannel(messenger, "com.github.rmtmckenzie/qr_mobile_vision");
    channel.setMethodCallHandler(this);
}
 
Example #5
Source File: FlutterIsolatePlugin.java    From flutter_isolate with MIT License 5 votes vote down vote up
private void setupChannel(BinaryMessenger messenger, Context context) {
    this.context = context;
    controlChannel = new MethodChannel(messenger, NAMESPACE + "/control");
    queuedIsolates = new LinkedList<>();
    activeIsolates = new HashMap<>();

    controlChannel.setMethodCallHandler(this);
}
 
Example #6
Source File: FlutterBarcodeScannerPlugin.java    From flutter_barcode_scanner with MIT License 5 votes vote down vote up
/**
 * Setup method
 * Created after Embedding V2 API release
 *
 * @param messenger
 * @param applicationContext
 * @param activity
 * @param registrar
 * @param activityBinding
 */
private void createPluginSetup(
        final BinaryMessenger messenger,
        final Application applicationContext,
        final Activity activity,
        final PluginRegistry.Registrar registrar,
        final ActivityPluginBinding activityBinding) {


    this.activity = (FlutterActivity) activity;
    eventChannel =
            new EventChannel(messenger, "flutter_barcode_scanner_receiver");
    eventChannel.setStreamHandler(this);


    this.applicationContext = applicationContext;
    channel = new MethodChannel(messenger, CHANNEL);
    channel.setMethodCallHandler(this);
    if (registrar != null) {
        // V1 embedding setup for activity listeners.
        observer = new LifeCycleObserver(activity);
        applicationContext.registerActivityLifecycleCallbacks(
                observer); // Use getApplicationContext() to avoid casting failures.
        registrar.addActivityResultListener(this);
    } else {
        // V2 embedding setup for activity listeners.
        activityBinding.addActivityResultListener(this);
        lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
        observer = new LifeCycleObserver(activity);
        lifecycle.addObserver(observer);
    }
}
 
Example #7
Source File: FlutterQiniucloudLivePlugin.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
private FlutterQiniucloudLivePlugin(BinaryMessenger messenger, Context context, MethodChannel channel, PlatformViewRegistry registry) {
    this.context = context;

    // 初始化七牛云
    StreamingEnv.init(context);

    // 初始化七牛云连麦
    RTCMediaStreamingManager.init(context, RTCServerRegion.RTC_CN_SERVER);

    // 注册View
    registry.registerViewFactory(QiniucloudPlayerPlatformView.SIGN, new QiniucloudPlayerPlatformView(context, messenger));
    registry.registerViewFactory(QiniucloudConnectedPlayerPlatformView.SIGN, new QiniucloudConnectedPlayerPlatformView(context, messenger));
    registry.registerViewFactory(QiniucloudPushPlatformView.SIGN, new QiniucloudPushPlatformView(context, messenger));
}
 
Example #8
Source File: FlutterDownloaderPlugin.java    From flutter_downloader with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void onAttachedToEngine(Context applicationContext, BinaryMessenger messenger) {
    synchronized (initializationLock) {
        if (flutterChannel != null) {
            return;
        }
        this.context = applicationContext;
        flutterChannel = new MethodChannel(messenger, CHANNEL);
        flutterChannel.setMethodCallHandler(this);
        dbHelper = TaskDbHelper.getInstance(context);
        taskDao = new TaskDao(dbHelper);
    }
}
 
Example #9
Source File: QiniucloudPlayerPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 4 votes vote down vote up
/**
 * 初始化视图工厂,注册视图时调用
 */
public QiniucloudPlayerPlatformView(Context context, BinaryMessenger messenger) {
    super(StandardMessageCodec.INSTANCE);
    this.context = context;
    this.messenger = messenger;
}
 
Example #10
Source File: QiniucloudConnectedPlayerPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 4 votes vote down vote up
/**
 * 初始化视图工厂,注册视图时调用
 */
public QiniucloudConnectedPlayerPlatformView(Context context, BinaryMessenger messenger) {
    super(StandardMessageCodec.INSTANCE);
    this.context = context;
    this.messenger = messenger;
}
 
Example #11
Source File: QiniucloudPushPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 4 votes vote down vote up
/**
 * 初始化视图工厂,注册视图时调用
 */
public QiniucloudPushPlatformView(Context context, BinaryMessenger messenger) {
    super(StandardMessageCodec.INSTANCE);
    this.context = context;
    this.messenger = messenger;
}
 
Example #12
Source File: ContactsServicePlugin.java    From flutter_contacts with MIT License 4 votes vote down vote up
private void initInstance(BinaryMessenger messenger, Context context) {
  methodChannel = new MethodChannel(messenger, "github.com/clovisnicolas/flutter_contacts");
  methodChannel.setMethodCallHandler(this);
  this.contentResolver = context.getContentResolver();
}
 
Example #13
Source File: SquareReaderSdkFlutterPlugin.java    From reader-sdk-flutter-plugin with Apache License 2.0 4 votes vote down vote up
private void onAttachedToEngine(Context context, BinaryMessenger messenger) {
  methodChannel = new MethodChannel(messenger, "square_reader_sdk");
  init(context);
}
 
Example #14
Source File: ZendeskPlugin.java    From flutter-zendesk with MIT License 4 votes vote down vote up
private void startListening(BinaryMessenger messenger) {
  channel = new MethodChannel(messenger, "com.codeheadlabs.zendesk");
  channel.setMethodCallHandler(methodCallHandler);
}
 
Example #15
Source File: StreamsChannel.java    From streams_channel with Apache License 2.0 4 votes vote down vote up
public StreamsChannel(BinaryMessenger messenger, String name) {
  this(messenger, name, StandardMethodCodec.INSTANCE);
}