Java Code Examples for io.flutter.plugin.common.PluginRegistry.Registrar#addRequestPermissionsResultListener()

The following examples show how to use io.flutter.plugin.common.PluginRegistry.Registrar#addRequestPermissionsResultListener() . 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: WifiPlugin.java    From wifi with MIT License 6 votes vote down vote up
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 2
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 3
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 4
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 5
Source File: FlutterImagePickCropPlugin.java    From FlutterImagePickCrop 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(), "flutter_image_pick_crop");

    FlutterImagePickCropPlugin instance = new FlutterImagePickCropPlugin(registrar.activity(), registrar.context(), channel);

    registrar.addRequestPermissionsResultListener(instance);
    registrar.addActivityResultListener(instance);
    channel.setMethodCallHandler(instance);

}
 
Example 6
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);
}
 
Example 7
Source File: OtaUpdatePlugin.java    From ota_update with MIT License 5 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {
    OtaUpdatePlugin plugin = new OtaUpdatePlugin(registrar);
    final EventChannel progressChannel = new EventChannel(registrar.messenger(), "sk.fourq.ota_update");
    progressChannel.setStreamHandler(plugin);
    registrar.addRequestPermissionsResultListener(plugin);
}
 
Example 8
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 9
Source File: BackgroundLocationUpdatesPlugin.java    From background_location_updates with Apache License 2.0 5 votes vote down vote up
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 10
Source File: PspdfkitPlugin.java    From pspdfkit-flutter 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(), "pspdfkit");
    PspdfkitPlugin pspdfkitPlugin = new PspdfkitPlugin(registrar);
    channel.setMethodCallHandler(pspdfkitPlugin);
    registrar.addRequestPermissionsResultListener(pspdfkitPlugin);
}
 
Example 11
Source File: MusicFinderPlugin.java    From Flute-Music-Player 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(), "music_finder");
  instance = new MusicFinderPlugin(registrar.activity(), channel);
  registrar.addRequestPermissionsResultListener(instance);
  channel.setMethodCallHandler(instance);

}
 
Example 12
Source File: SmsPlugin.java    From flutter_sms with MIT License 4 votes vote down vote up
/**
 * Plugin registration.
 */
public static void registerWith(Registrar registrar) {

    registrar.addRequestPermissionsResultListener(Permissions.getRequestsResultsListener());

    // SMS receiver
    final SmsReceiver receiver = new SmsReceiver(registrar);
    final EventChannel receiveSmsChannel = new EventChannel(registrar.messenger(),
            CHANNEL_RECV, JSONMethodCodec.INSTANCE);
    receiveSmsChannel.setStreamHandler(receiver);

    // SMS status receiver
    new EventChannel(registrar.messenger(), CHANNEL_SMS_STATUS, JSONMethodCodec.INSTANCE)
            .setStreamHandler(new SmsStateHandler(registrar));

    /// SMS sender
    final SmsSender sender = new SmsSender(registrar);
    final MethodChannel sendSmsChannel = new MethodChannel(registrar.messenger(),
            CHANNEL_SEND, JSONMethodCodec.INSTANCE);
    sendSmsChannel.setMethodCallHandler(sender);

    /// SMS query
    final SmsQuery query = new SmsQuery(registrar);
    final MethodChannel querySmsChannel = new MethodChannel(registrar.messenger(), CHANNEL_QUER, JSONMethodCodec.INSTANCE);
    querySmsChannel.setMethodCallHandler(query);

    /// Contact query
    final ContactQuery contactQuery = new ContactQuery(registrar);
    final MethodChannel queryContactChannel = new MethodChannel(registrar.messenger(), CHANNEL_QUER_CONT, JSONMethodCodec.INSTANCE);
    queryContactChannel.setMethodCallHandler(contactQuery);

    /// Contact Photo query
    final ContactPhotoQuery contactPhotoQuery = new ContactPhotoQuery(registrar);
    final MethodChannel queryContactPhotoChannel = new MethodChannel(registrar.messenger(), CHANNEL_QUER_CONT_PHOTO, StandardMethodCodec.INSTANCE);
    queryContactPhotoChannel.setMethodCallHandler(contactPhotoQuery);

    /// User Profile
    final UserProfileProvider userProfileProvider = new UserProfileProvider(registrar);
    final MethodChannel userProfileProviderChannel = new MethodChannel(registrar.messenger(), CHANNEL_USER_PROFILE, JSONMethodCodec.INSTANCE);
    userProfileProviderChannel.setMethodCallHandler(userProfileProvider);

    //Sim Cards Provider
    new MethodChannel(registrar.messenger(), CHANNEL_SIM_CARDS, JSONMethodCodec.INSTANCE)
            .setMethodCallHandler(new SimCardsProvider(registrar));
}
 
Example 13
Source File: FastQrReaderViewPlugin.java    From fast_qr_reader_view with MIT License 4 votes vote down vote up
private FastQrReaderViewPlugin(Registrar registrar, FlutterView view, Activity activity) {

        this.registrar = registrar;
        this.view = view;
        this.activity = activity;

        registrar.addRequestPermissionsResultListener(new CameraRequestPermissionsListener());

        this.activityLifecycleCallbacks =
                new Application.ActivityLifecycleCallbacks() {
                    @Override
                    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
                    }

                    @Override
                    public void onActivityStarted(Activity activity) {
                    }

                    @Override
                    public void onActivityResumed(Activity activity) {
                        if (requestingPermission) {
                            requestingPermission = false;
                            return;
                        }
                        if (activity == FastQrReaderViewPlugin.this.activity) {
                            if (camera != null) {
                                camera.startCameraSource();
                            }
                        }
                    }

                    @Override
                    public void onActivityPaused(Activity activity) {
                        if (activity == FastQrReaderViewPlugin.this.activity) {
                            if (camera != null) {
                                if (camera.preview != null) {
                                    camera.preview.stop();

                                }
                            }
                        }
                    }

                    @Override
                    public void onActivityStopped(Activity activity) {
                        if (activity == FastQrReaderViewPlugin.this.activity) {
                            if (camera != null) {
                                if (camera.preview != null) {
                                    camera.preview.stop();
                                }

                                if (camera.cameraSource != null) {
                                    camera.cameraSource.release();
                                }
                            }
                        }
                    }

                    @Override
                    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
                    }

                    @Override
                    public void onActivityDestroyed(Activity activity) {

                    }
                };
    }