Java Code Examples for io.flutter.plugin.common.PluginRegistry.Registrar#activity()
The following examples show how to use
io.flutter.plugin.common.PluginRegistry.Registrar#activity() .
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: QrMobileVisionPlugin.java From flutter_qr_mobile_vision with MIT License | 6 votes |
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 2
Source File: OtaUpdatePlugin.java From ota_update with MIT License | 6 votes |
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 3
Source File: WifiPlugin.java From wifi with MIT License | 6 votes |
public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), "plugins.ly.com/wifi"); WifiManager wifiManager = (WifiManager) registrar.activeContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE); final WifiDelegate delegate = new WifiDelegate(registrar.activity(), wifiManager); registrar.addRequestPermissionsResultListener(delegate); // support Android O,listen network disconnect event // https://stackoverflow.com/questions/50462987/android-o-wifimanager-enablenetwork-cannot-work IntentFilter filter = new IntentFilter(); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); registrar .context() .registerReceiver(delegate.networkReceiver,filter); channel.setMethodCallHandler(new WifiPlugin(registrar, delegate)); }
Example 4
Source File: AdvCameraPlugin.java From adv_camera with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 5
Source File: FastQrReaderViewPlugin.java From fast_qr_reader_view with MIT License | 5 votes |
/** * 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 6
Source File: DeviceAppsPlugin.java From flutter_plugin_device_apps with Apache License 2.0 | 5 votes |
/** * 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 7
Source File: WifiIotPlugin.java From WiFiFlutter with MIT License | 5 votes |
/** * 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 8
Source File: OpenFilePlugin.java From open_file with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); }
Example 9
Source File: FlutterImagePickCropPlugin.java From FlutterImagePickCrop with Apache License 2.0 | 5 votes |
/** * Plugin registration. */ public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_image_pick_crop"); FlutterImagePickCropPlugin instance = new FlutterImagePickCropPlugin(registrar.activity(), registrar.context(), channel); registrar.addRequestPermissionsResultListener(instance); registrar.addActivityResultListener(instance); channel.setMethodCallHandler(instance); }
Example 10
Source File: MusicFinderPlugin.java From Flute-Music-Player with Apache License 2.0 | 5 votes |
/** * Plugin registration. */ public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), "music_finder"); instance = new MusicFinderPlugin(registrar.activity(), channel); registrar.addRequestPermissionsResultListener(instance); channel.setMethodCallHandler(instance); }
Example 11
Source File: BackgroundLocationUpdatesPlugin.java From background_location_updates with Apache License 2.0 | 5 votes |
private BackgroundLocationUpdatesPlugin(Registrar registrar) { this.mContext = registrar.context(); this.mActivity = registrar.activity(); new EventChannel(registrar.messenger(), "plugins.gjg.io/background_location_updates/tracking_state") .setStreamHandler(this); RequestPermissionsHandler requestPermissionsHandler = new RequestPermissionsHandler(mContext); registrar.addRequestPermissionsResultListener(requestPermissionsHandler); new EventChannel(registrar.messenger(), "plugins.gjg.io/background_location_updates/permission_state") .setStreamHandler(requestPermissionsHandler); }
Example 12
Source File: FlutterExifRotationPlugin.java From flutter_exif_rotation with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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: SocialSharePlugin.java From social_share_plugin with BSD 2-Clause "Simplified" License | 5 votes |
/** * Plugin registration. */ public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), "social_share_plugin"); final SocialSharePlugin plugin = new SocialSharePlugin(); plugin.channel = channel; plugin.activity = registrar.activity(); channel.setMethodCallHandler(plugin); }
Example 14
Source File: FlutterBraintreeDropIn.java From FlutterBraintree with MIT License | 5 votes |
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 15
Source File: FlutterBraintreePlugin.java From FlutterBraintree with MIT License | 5 votes |
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 16
Source File: SquareReaderSdkFlutterPlugin.java From reader-sdk-flutter-plugin with Apache License 2.0 | 4 votes |
public static void registerWith(Registrar registrar) { SquareReaderSdkFlutterPlugin instance = new SquareReaderSdkFlutterPlugin(registrar.activity()); instance.onAttachedToEngine(registrar.activity(), registrar.messenger()); methodChannel.setMethodCallHandler(instance); }
Example 17
Source File: RazorpayFlutterPlugin.java From razorpay-flutter with MIT License | 4 votes |
/** * Constructor for Flutter version < 1.12 * @param registrar */ private RazorpayFlutterPlugin(Registrar registrar) { this.razorpayDelegate = new RazorpayDelegate(registrar.activity()); registrar.addActivityResultListener(razorpayDelegate); }
Example 18
Source File: FlutterMultipleImagePickerPlugin.java From FlutterMulti-ImagePicker with Apache License 2.0 | 4 votes |
public static void registerWith(Registrar registrar) { final MethodChannel channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME); FlutterMultipleImagePickerPlugin instance = new FlutterMultipleImagePickerPlugin(registrar.activity(), registrar.context(), channel); registrar.addActivityResultListener(instance); channel.setMethodCallHandler(instance); }
Example 19
Source File: AdvCameraPlugin.java From adv_camera with BSD 3-Clause "New" or "Revised" License | 4 votes |
private AdvCameraPlugin(Registrar registrar) { this.activity = registrar.activity(); }
Example 20
Source File: MedcorderAudioPlugin.java From flutter_audio with MIT License | 3 votes |
public static void registerWith(Registrar registrar) { final MedcorderAudioPlugin plugin = new MedcorderAudioPlugin(registrar.activity()); final MethodChannel methodChannel = new MethodChannel(registrar.messenger(), "medcorder_audio"); methodChannel.setMethodCallHandler(plugin); final EventChannel eventChannel = new EventChannel(registrar.messenger(), "medcorder_audio_events"); eventChannel.setStreamHandler(plugin); }