Example usage for org.apache.cordova CordovaPlugin requestPermissions

List of usage examples for org.apache.cordova CordovaPlugin requestPermissions

Introduction

In this page you can find the example usage for org.apache.cordova CordovaPlugin requestPermissions.

Prototype


public void requestPermissions(int requestCode) 

Source Link

Document

Called by the Plugin Manager when we need to actually request permissions

Usage

From source file:com.zsxsoft.cordova.x5.X5WebChromeClient.java

License:Apache License

@Override
/**/* w w w.  jav  a 2  s.  c  o m*/
 * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
 *
 * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
 *
 * @param origin
 * @param callback
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
    super.onGeolocationPermissionsShowPrompt(origin, callback);
    callback.invoke(origin, true, false);
    //Get the plugin, it should be loaded
    CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
    if (geolocation != null && !geolocation.hasPermisssion()) {
        geolocation.requestPermissions(0);
    }

}

From source file:org.jeremyup.cordova.x5engine.X5WebChromeClient.java

License:Apache License

/**
 * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
 *
 * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
 *
 * @param origin/* www  .  j  a  v a2 s.c  o m*/
 * @param callback
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
    super.onGeolocationPermissionsShowPrompt(origin, callback);
    callback.invoke(origin, true, false);
    //Get the plugin, it should be loaded
    CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
    if (geolocation != null && !geolocation.hasPermisssion()) {
        geolocation.requestPermissions(0);
    }

}