io.flutter.plugin.common.PluginRegistry.Registrar Java Examples

The following examples show how to use io.flutter.plugin.common.PluginRegistry.Registrar. 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: FlutterYoutubePlugin.java    From FlutterYoutube with Apache License 2.0 6 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "PonnamKarthik/flutter_youtube");
  channel.setMethodCallHandler(new FlutterYoutubePlugin(registrar.activity()));
  registrar.addActivityResultListener(new PluginRegistry.ActivityResultListener() {
    @Override
    public boolean onActivityResult(int i, int i1, Intent intent) {
      if(i == YOUTUBE_PLAYER_RESULT) {
        if(intent != null) {
          if(intent.getIntExtra("done", -1) == 0) {
            if(events != null) {
              events.success("done");
            }
          }
        }
      }
      return false;
    }
  });

  final EventChannel eventChannel = new EventChannel(registrar.messenger(), STREAM_CHANNEL_NAME);
  FlutterYoutubePlugin youtubeWithEventChannel = new FlutterYoutubePlugin(registrar.activity());
  eventChannel.setStreamHandler(youtubeWithEventChannel);
}
 
Example #2
Source File: FlutterExifRotationPlugin.java    From flutter_exif_rotation with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public FlutterExifRotationPlugin(Registrar registrar, final Activity activity) {

        this.registrar = registrar;

        permissionManager = new PermissionManager() {
            @Override
            public boolean isPermissionGranted(String permissionName) {
                return ActivityCompat.checkSelfPermission(activity, permissionName)
                        == PackageManager.PERMISSION_GRANTED;
            }

            @Override
            public void askForPermission(String[] permissions, int requestCode) {
                ActivityCompat.requestPermissions(activity, permissions, requestCode);
            }

        };
    }
 
Example #3
Source File: OtaUpdatePlugin.java    From ota_update with MIT License 6 votes vote down vote up
private OtaUpdatePlugin(Registrar registrar) {
    this.registrar = registrar;
    context = (registrar.activity() != null) ? registrar.activity() : registrar.context();
    handler = new Handler(context.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (progressSink != null) {
                Bundle data = msg.getData();
                if (data.containsKey(ERROR)) {
                    reportError(OtaStatus.DOWNLOAD_ERROR, data.getString(ERROR));
                } else {
                    long bytesDownloaded = data.getLong(BYTES_DOWNLOADED);
                    long bytesTotal = data.getLong(BYTES_TOTAL);
                    progressSink.success(Arrays.asList("" + OtaStatus.DOWNLOADING.ordinal(), "" + ((bytesDownloaded * 100) / bytesTotal)));
                }
            }
        }
    };
}
 
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: 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 #6
Source File: FlutterPluginPlaylistPlugin.java    From flutter_plugin_playlist with MIT License 6 votes vote down vote up
/** Plugin registration. */
public static void registerWith(final Registrar registrar) {
  PlaylistManager.init(registrar.activity().getApplication());

  MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_plugin_playlist");

  // Plugin instance
  FlutterPluginPlaylistPlugin plugin = new FlutterPluginPlaylistPlugin(channel);

  // register the plugin as the method call handler
  channel.setMethodCallHandler(plugin);

  // create and link the audioPlayer with the plugin
  plugin.audioPlayerImpl = new RmxAudioPlayer(plugin);

  PlaylistManager.getInstance().registerProgressListener(plugin.audioPlayerImpl);
  PlaylistManager.getInstance().registerPlaylistListener(plugin.audioPlayerImpl);

  AudioTrack.setAssetResolver(new AudioTrack.AssetResolver() {
    @Override
    public String getAsset(String asset) {
      return Uri.parse("/android_asset/" + registrar.lookupKeyForAsset(asset)).toString();
    }
  });
}
 
Example #7
Source File: EsensePlugin.java    From flutter-plugins with MIT License 6 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  final MethodChannel channel = new MethodChannel(registrar.messenger(), "esense");
  channel.setMethodCallHandler(new EsensePlugin());

  registrar.activity().requestPermissions(new String[]{
          Manifest.permission.ACCESS_COARSE_LOCATION,
          Manifest.permission.ACCESS_FINE_LOCATION,
  }, 0);

  final  ESenseConnectionEventStreamHandler eSenseConnectionEventStreamHandler = new ESenseConnectionEventStreamHandler(registrar);
  final ESenseManagerMethodCallHandler eSenseManagerMethodCallHandler = new ESenseManagerMethodCallHandler(registrar,eSenseConnectionEventStreamHandler);

  final MethodChannel eSenseManagerMethodChannel = new MethodChannel(registrar.messenger(), ESenseManagerMethodChannelName);
  eSenseManagerMethodChannel.setMethodCallHandler(eSenseManagerMethodCallHandler);

  final EventChannel eSenseConnectionEventChannel = new EventChannel(registrar.messenger(), ESenseConnectionEventChannelName);
  eSenseConnectionEventChannel.setStreamHandler(eSenseConnectionEventStreamHandler);

  final EventChannel eSenseEventChannel = new EventChannel(registrar.messenger(), ESenseEventEventChannelName);
  eSenseEventChannel.setStreamHandler(new ESenseEventStreamHandler(eSenseManagerMethodCallHandler));

  final EventChannel eSenseSensorEventChannel = new EventChannel(registrar.messenger(), ESenseSensorEventChannelName);
  eSenseSensorEventChannel.setStreamHandler(new ESenseSensorEventStreamHandler(eSenseManagerMethodCallHandler));
}
 
Example #8
Source File: EsenseFlutterPlugin.java    From flutter-plugins with MIT License 6 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  registrar.activity().requestPermissions(new String[]{
          Manifest.permission.ACCESS_COARSE_LOCATION,
          Manifest.permission.ACCESS_FINE_LOCATION,
  }, 0);

  final  ESenseConnectionEventStreamHandler eSenseConnectionEventStreamHandler = new ESenseConnectionEventStreamHandler(registrar);
  final ESenseManagerMethodCallHandler eSenseManagerMethodCallHandler = new ESenseManagerMethodCallHandler(registrar,eSenseConnectionEventStreamHandler);

  final MethodChannel eSenseManagerMethodChannel = new MethodChannel(registrar.messenger(), ESenseManagerMethodChannelName);
  eSenseManagerMethodChannel.setMethodCallHandler(eSenseManagerMethodCallHandler);

  final EventChannel eSenseConnectionEventChannel = new EventChannel(registrar.messenger(), ESenseConnectionEventChannelName);
  eSenseConnectionEventChannel.setStreamHandler(eSenseConnectionEventStreamHandler);

  final EventChannel eSenseEventChannel = new EventChannel(registrar.messenger(), ESenseEventEventChannelName);
  eSenseEventChannel.setStreamHandler(new ESenseEventStreamHandler(eSenseManagerMethodCallHandler));

  final EventChannel eSenseSensorEventChannel = new EventChannel(registrar.messenger(), ESenseSensorEventChannelName);
  eSenseSensorEventChannel.setStreamHandler(new ESenseSensorEventStreamHandler(eSenseManagerMethodCallHandler));
}
 
Example #9
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 #10
Source File: AdvCameraPlugin.java    From adv_camera with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void registerWith(Registrar registrar) {
    if (registrar.activity() == null) {
        // When a background flutter view tries to register the plugin, the registrar has no activity.
        // We stop the registration process as this plugin is foreground only.
        return;
    }

    registrar
            .platformViewRegistry()
            .registerViewFactory(
                    "plugins.flutter.io/adv_camera", new AdvCameraFactory(registrar));

    final MethodChannel channel = new MethodChannel(registrar.messenger(), "adv_camera");
    channel.setMethodCallHandler(new AdvCameraPlugin(registrar));
}
 
Example #11
Source File: WifiIotPlugin.java    From WiFiFlutter with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    if (registrar.activity() == null) {
        // When a background flutter view tries to register the plugin, the registrar has no activity.
        // We stop the registration process as this plugin is foreground only.
        return;
    }
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "wifi_iot");
    final EventChannel eventChannel = new EventChannel(registrar.messenger(), "plugins.wififlutter.io/wifi_scan");
    final WifiIotPlugin wifiIotPlugin = new WifiIotPlugin(registrar.activity());
    eventChannel.setStreamHandler(wifiIotPlugin);
    channel.setMethodCallHandler(wifiIotPlugin);

    registrar.addViewDestroyListener(new ViewDestroyListener() {
        @Override
        public boolean onViewDestroy(FlutterNativeView view) {
            if (!wifiIotPlugin.ssidsToBeRemovedOnExit.isEmpty()) {
                List<WifiConfiguration> wifiConfigList =
                        wifiIotPlugin.moWiFi.getConfiguredNetworks();
                for (String ssid : wifiIotPlugin.ssidsToBeRemovedOnExit) {
                    for (WifiConfiguration wifiConfig : wifiConfigList) {
                        if (wifiConfig.SSID.equals(ssid)) {
                            wifiIotPlugin.moWiFi.removeNetwork(wifiConfig.networkId);
                        }
                    }
                }
            }
            return false;
        }
    });
}
 
Example #12
Source File: FileHelper.java    From simple_share with MIT License 5 votes vote down vote up
FileHelper(Registrar registrar, String url, String type) {
    this.registrar = registrar;
    this.authorities = registrar.context().getPackageName() + SHARED_PROVIDER_AUTHORITY;
    this.url = url;
    this.uri = Uri.parse(url);
    this.type = type;
}
 
Example #13
Source File: AeyriumSensorPlugin.java    From aeyrium-sensor with MIT License 5 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  final EventChannel sensorChannel =
          new EventChannel(registrar.messenger(), SENSOR_CHANNEL_NAME);
  sensorChannel.setStreamHandler(
          new AeyriumSensorPlugin(registrar.context(), Sensor.TYPE_ROTATION_VECTOR, registrar));

}
 
Example #14
Source File: FastQrReaderViewPlugin.java    From fast_qr_reader_view with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    channel =
            new MethodChannel(registrar.messenger(), "fast_qr_reader_view");

    cameraManager = (CameraManager) registrar.activity().getSystemService(Context.CAMERA_SERVICE);

    channel.setMethodCallHandler(
            new FastQrReaderViewPlugin(registrar, registrar.view(), registrar.activity()));

    FastQrReaderViewPlugin plugin = new FastQrReaderViewPlugin(registrar, registrar.view(), registrar.activity());
    channel.setMethodCallHandler(plugin);
    registrar.addRequestPermissionsResultListener(plugin);
}
 
Example #15
Source File: NotificationsPlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
    final EventChannel channel = new EventChannel(registrar.messenger(), EVENT_CHANNEL_NAME);
    Context context = registrar.activeContext();
    NotificationsPlugin plugin = new NotificationsPlugin(context);
    channel.setStreamHandler(plugin);
}
 
Example #16
Source File: FlutterAmapPlugin.java    From flutter_amap_plugin with MIT License 5 votes vote down vote up
public static void registerWith(Registrar registrar) {
    FlutterAmapPlugin.registrar = registrar;

    final MethodChannel channel = new MethodChannel(registrar.messenger(), MAP_BASE_CHANNEL);
    channel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity()));

    final MethodChannel locChannel = new MethodChannel(registrar.messenger(), LOCATION_CHANNEL_NAME);
    locChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity()));
    FlutterAmapPlugin.locChannel = locChannel;

    final MethodChannel routeChannel = new MethodChannel(registrar.messenger(), SEARCH_ROUTE_CHANNEL_NAME);
    routeChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity()));
    FlutterAmapPlugin.routeChannel = routeChannel;

    final MethodChannel convertChannel = new MethodChannel(registrar.messenger(), SEARCH_CONVERT_CHANNEL_NAME);
    convertChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity()));
    FlutterAmapPlugin.convertChannel = convertChannel;

    final MethodChannel navChannel = new MethodChannel(registrar.messenger(), FlutterAMapNavView.NAV_CHANNEL_NAME);
    navChannel.setMethodCallHandler(new FlutterAmapPlugin((FlutterActivity) registrar.activity()));

    final FlutterAmapPlugin plugin = new FlutterAmapPlugin(root);

    registrar.platformViewRegistry().registerViewFactory(FlutterAMapView.MAP_CHANNEL_NAME,
            new FlutterAMapViewFactory(plugin.state, registrar));
    registrar.platformViewRegistry().registerViewFactory(FlutterAMapNavView.NAV_CHANNEL_NAME,
            new FlutterAMapNavFactory(plugin.state, registrar));
}
 
Example #17
Source File: MovisensFlutterPlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
public MovisensFlutterPlugin(Registrar registrar) {
        this.registrar = registrar;
//        Log.v("Flutter Plugin", "Constructor");
        /// Set up the intent filter
        MovisensEventReceiver receiver = new MovisensEventReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(MovisensService.MOVISENS_INTENT_NAME);
        registrar.context().registerReceiver(receiver, intentFilter);
    }
 
Example #18
Source File: JmessageFlutterPlugin.java    From jmessage-flutter-plugin with MIT License 5 votes vote down vote up
private JmessageFlutterPlugin(Registrar registrar, MethodChannel channel) {

    this.registrar = registrar;
    this.channel = channel;
    JmessageFlutterPlugin.instance = this;
    mContext = registrar.context();
  }
 
Example #19
Source File: DeviceAppsPlugin.java    From flutter_plugin_device_apps with Apache License 2.0 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    final MethodChannel channel = new MethodChannel(registrar.messenger(), "g123k/device_apps");
    DeviceAppsPlugin plugin = new DeviceAppsPlugin(registrar.activity());
    registrar.addViewDestroyListener(plugin);
    channel.setMethodCallHandler(plugin);
}
 
Example #20
Source File: LightPlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
  final EventChannel eventChannel =
          new EventChannel(registrar.messenger(), STEP_COUNT_CHANNEL_NAME);
  eventChannel.setStreamHandler(
          new LightPlugin(registrar.context(), Sensor.TYPE_LIGHT));
}
 
Example #21
Source File: PedometerPlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
  final EventChannel eventChannel =
          new EventChannel(registrar.messenger(), STEP_COUNT_CHANNEL_NAME);
  eventChannel.setStreamHandler(
          new PedometerPlugin(registrar.context(), Sensor.TYPE_STEP_COUNTER));
}
 
Example #22
Source File: AmapLocationPlugin.java    From location_plugin with Apache License 2.0 5 votes vote down vote up
AmapLocationPlugin(Registrar registrar) {
	this.registrar = registrar;
	//初始化定位
	mLocationClient = new AMapLocationClient(registrar.context());

	//设置定位回调监听
	mLocationClient.setLocationListener(mAMapLocationListener);
}
 
Example #23
Source File: WhatsAppStickersPlugin.java    From flutter_whatsapp_stickers with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private WhatsAppStickersPlugin(Registrar registrar, MethodChannel channel) {
    this.registrar = registrar;
    this.channel = channel;

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(StickerPackActivity.ACTION_STICKER_PACK_RESULT);
    intentFilter.addAction(StickerPackActivity.ACTION_STICKER_PACK_ERROR);
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(registrar.context());
    manager.registerReceiver(this, intentFilter);
}
 
Example #24
Source File: MovisensFlutterPlugin.java    From flutter-plugins with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    // Set up plugin instance
    MovisensFlutterPlugin plugin = new MovisensFlutterPlugin(registrar);

    // Set up method channel
    final MethodChannel methodChannel = new MethodChannel(registrar.messenger(), "movisens.method_channel");
    methodChannel.setMethodCallHandler(plugin);

    // Set up event channel
    final EventChannel eventChannel = new EventChannel(registrar.messenger(), "movisens.event_channel");
    eventChannel.setStreamHandler(plugin);
}
 
Example #25
Source File: MediaNotificationPlugin.java    From flutter_media_notification with Apache License 2.0 5 votes vote down vote up
/** Plugin registration. */
public static void registerWith(Registrar registrar) {
  MediaNotificationPlugin plugin = new MediaNotificationPlugin(registrar);

  MediaNotificationPlugin.channel = new MethodChannel(registrar.messenger(), "media_notification");
  MediaNotificationPlugin.channel.setMethodCallHandler(new MediaNotificationPlugin(registrar));
}
 
Example #26
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 #27
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 #28
Source File: Request.java    From play_games with MIT License 5 votes vote down vote up
public Request(PlayGamesPlugin pluginRef, GoogleSignInAccount currentAccount, Registrar registrar, MethodCall call, Result result) {
    this.pluginRef = pluginRef;
    this.currentAccount = currentAccount;
    this.registrar = registrar;
    this.call = call;
    this.result = result;
}
 
Example #29
Source File: NativeDeviceOrientationPlugin.java    From flutter_native_device_orientation with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    final MethodChannel methodChannel = new MethodChannel(registrar.messenger(), METHOD_CHANEL);
    final EventChannel eventChannel = new EventChannel(registrar.messenger(), EVENT_CHANNEL);
    final NativeDeviceOrientationPlugin instance = new NativeDeviceOrientationPlugin(registrar.activeContext());

    methodChannel.setMethodCallHandler(instance);
    eventChannel.setStreamHandler(instance);
}
 
Example #30
Source File: OpenFilePlugin.java    From open_file with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void registerWith(Registrar registrar) {
    OpenFilePlugin plugin = new OpenFilePlugin();
    plugin.activity = registrar.activity();
    plugin.context = registrar.context();
    plugin.channel = new MethodChannel(registrar.messenger(), "open_file");
    plugin.channel.setMethodCallHandler(plugin);
    registrar.addRequestPermissionsResultListener(plugin);
    registrar.addActivityResultListener(plugin);
}