Java Code Examples for io.flutter.plugin.common.MethodChannel#setMethodCallHandler()

The following examples show how to use io.flutter.plugin.common.MethodChannel#setMethodCallHandler() . 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: FlutterAMapNavView.java    From flutter_amap_plugin with MIT License 6 votes vote down vote up
public FlutterAMapNavView(Context context, AtomicInteger atomicInteger, PluginRegistry.Registrar registrar, int id, Activity activity, AMapNavModel model) {
    this.context = context;
    this.atomicInteger = atomicInteger;
    this.registrar = registrar;
    this.mOptions = model;
    this.activity = activity;

    navChannel = new MethodChannel(registrar.messenger(), NAV_CHANNEL_NAME + "/" + id);
    navChannel.setMethodCallHandler(this);

    aMapNav = AMapNavi.getInstance(activity);
    aMapNav.addAMapNaviListener(this);
    aMapNav = AMapNavi.getInstance(this.context);
    aMapNav.setUseInnerVoice(true);

    view = View.inflate(activity, R.layout.amap_nav, null);
    navView = view.findViewById(R.id.navi_view);

    registrar.activity().getApplication().registerActivityLifecycleCallbacks(this);
}
 
Example 2
Source File: QrReaderView.java    From flutter_qr_reader with MIT License 6 votes vote down vote up
public QrReaderView(Context context, PluginRegistry.Registrar registrar, int id, Map<String, Object> params){
    this.mContext = context;
    this.mParams = params;
    this.mRegistrar = registrar;

    // 创建视图
    int width = (int) mParams.get("width");
    int height = (int) mParams.get("height");
    _view = new QRCodeReaderView(mContext);
    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(width, height);
    _view.setLayoutParams(layoutParams);
    _view.setOnQRCodeReadListener(this);
    _view.setQRDecodingEnabled(true);
    _view.forceAutoFocus();
    int interval = mParams.containsKey(EXTRA_FOCUS_INTERVAL) ? (int) mParams.get(EXTRA_FOCUS_INTERVAL) : 2000;
    _view.setAutofocusInterval(interval);
    _view.setTorchEnabled((boolean)mParams.get(EXTRA_TORCH_ENABLED));

    // 操作监听
    mMethodChannel = new MethodChannel(registrar.messenger(), "me.hetian.flutter_qr_reader.reader_view_" + id);
    mMethodChannel.setMethodCallHandler(this);
}
 
Example 3
Source File: QiniucloudConnectedPlayerPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
@Override
public PlatformView create(Context context, int viewId, Object args) {
    this.viewId = viewId;
    Map<String, Object> params = (Map<String, Object>) args;
    QiniucloudConnectedPlayerPlatformView view = new QiniucloudConnectedPlayerPlatformView(context);
    // 绑定方法监听器
    MethodChannel methodChannel = new MethodChannel(messenger, SIGN + "_" + viewId);
    methodChannel.setMethodCallHandler(view);
    // 初始化
    view.init(params, methodChannel);
    // 添加到视图队列
    ConnectedUtil.add(this.viewId, view);
    return view;
}
 
Example 4
Source File: FlutterQrReaderPlugin.java    From flutter_qr_reader with MIT License 5 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
  registrar.platformViewRegistry().registerViewFactory(CHANNEL_VIEW_NAME, new QrReaderFactory(registrar));
  final FlutterQrReaderPlugin instance = new FlutterQrReaderPlugin(registrar);
  channel.setMethodCallHandler(instance);
}
 
Example 5
Source File: QiniucloudPlayerPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
@Override
public PlatformView create(Context context, int viewId, Object args) {
    Map<String, Object> params = (Map<String, Object>) args;
    QiniucloudPlayerPlatformView view = new QiniucloudPlayerPlatformView(context);
    // 绑定方法监听器
    MethodChannel methodChannel = new MethodChannel(messenger, SIGN + "_" + viewId);
    methodChannel.setMethodCallHandler(view);
    // 初始化
    view.init(params, methodChannel);
    return view;
}
 
Example 6
Source File: ImeiPlugin.java    From imei_plugin with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 * add Listener Request permission
 */
public static void registerWith(Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "imei_plugin");
    ImeiPlugin imeiPlugin = new ImeiPlugin(registrar.activity(), registrar.context().getContentResolver());
    channel.setMethodCallHandler(imeiPlugin);
    registrar.addRequestPermissionsResultListener(imeiPlugin);
}
 
Example 7
Source File: FlutterBraintreeDropIn.java    From FlutterBraintree with MIT License 5 votes vote down vote up
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_braintree.drop_in");
  FlutterBraintreeDropIn dropIn = new FlutterBraintreeDropIn();
  dropIn.activity = registrar.activity();
  registrar.addActivityResultListener(dropIn);
  channel.setMethodCallHandler(dropIn);
}
 
Example 8
Source File: FlutterBraintreePlugin.java    From FlutterBraintree with MIT License 5 votes vote down vote up
public static void registerWith(Registrar registrar) {
  FlutterBraintreeDropIn.registerWith(registrar);
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_braintree.custom");
  FlutterBraintreePlugin plugin = new FlutterBraintreePlugin();
  plugin.activity = registrar.activity();
  registrar.addActivityResultListener(plugin);
  channel.setMethodCallHandler(plugin);
}
 
Example 9
Source File: QiniucloudPushPlatformView.java    From FlutterQiniucloudLivePlugin with Apache License 2.0 5 votes vote down vote up
@Override
public PlatformView create(Context context, int viewId, Object args) {
    Map<String, Object> params = (Map<String, Object>) args;
    QiniucloudPushPlatformView view = new QiniucloudPushPlatformView(context);
    // 绑定方法监听器
    MethodChannel methodChannel = new MethodChannel(messenger, SIGN + "_" + viewId);
    methodChannel.setMethodCallHandler(view);
    // 初始化
    view.init(params, methodChannel);
    return view;
}
 
Example 10
Source File: FlutterUploaderPlugin.java    From flutter_uploader with MIT License 5 votes vote down vote up
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
  final FlutterUploaderPlugin plugin = new FlutterUploaderPlugin(registrar, channel);
  channel.setMethodCallHandler(plugin);

  if (registrar.activity() != null) {
    registrar.activity().getApplication().registerActivityLifecycleCallbacks(plugin);
  }
}
 
Example 11
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 12
Source File: FlutterExifRotationPlugin.java    From flutter_exif_rotation with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_exif_rotation");
    FlutterExifRotationPlugin flutterExifRotationPlugin = new FlutterExifRotationPlugin(registrar, registrar.activity());
    channel.setMethodCallHandler(flutterExifRotationPlugin);
    registrar.addRequestPermissionsResultListener(flutterExifRotationPlugin);
}
 
Example 13
Source File: FlutterUmplusPlugin.java    From flutter_umplus with MIT License 4 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  final MethodChannel channel =
      new MethodChannel(registrar.messenger(), "ygmpkk/flutter_umplus");
  channel.setMethodCallHandler(new FlutterUmplusPlugin(registrar.activity()));
}
 
Example 14
Source File: TencentImPlugin.java    From FlutterTencentImPlugin with Apache License 2.0 4 votes vote down vote up
@Override
public void onAttachedToEngine(FlutterPluginBinding flutterPluginBinding) {
    final MethodChannel channel = new MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), "tencent_im_plugin");
    channel.setMethodCallHandler(new TencentImPlugin(flutterPluginBinding.getApplicationContext(), channel));
}
 
Example 15
Source File: WhatsAppStickersPlugin.java    From flutter_whatsapp_stickers with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static void registerWith(Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(),
            "io.github.vincekruger/whatsapp_stickers");
    final WhatsAppStickersPlugin plugin = new WhatsAppStickersPlugin(registrar, channel);
    channel.setMethodCallHandler(plugin);
}
 
Example 16
Source File: FlutterSplashScreenPlugin.java    From flutter_splash_screen with MIT License 4 votes vote down vote up
public static void registerWith(Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_splash_screen");
    channel.setMethodCallHandler(new FlutterSplashScreenPlugin(registrar.activity()));
}
 
Example 17
Source File: FlutterBraintreeDropIn.java    From FlutterBraintree with MIT License 4 votes vote down vote up
@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
  final MethodChannel channel = new MethodChannel(binding.getBinaryMessenger(), "flutter_braintree.drop_in");
  channel.setMethodCallHandler(this);
}
 
Example 18
Source File: RazorpayFlutterPlugin.java    From razorpay-flutter with MIT License 4 votes vote down vote up
@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {
    final MethodChannel channel = new MethodChannel(binding.getBinaryMessenger(), CHANNEL_NAME);
    channel.setMethodCallHandler(this);
}
 
Example 19
Source File: LeancloudFlutterPlugin.java    From leancloud_flutter_plugin with MIT License 4 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "leancloud_flutter_plugin");
  channel.setMethodCallHandler(new LeancloudFlutterPlugin());
  _applicationContext = registrar.context().getApplicationContext();
}
 
Example 20
Source File: AudioPlayerPlugin.java    From flutter_exoplayer with MIT License 4 votes vote down vote up
public static void registerWith(final Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "danielr2001/audioplayer");
  channel.setMethodCallHandler(new AudioPlayerPlugin(channel, registrar.activity()));
}