Github user dpogue commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/409#discussion_r44179259
  
    --- Diff: www/docs/en/edge/guide/platforms/android/plugin.md ---
    @@ -259,9 +259,100 @@ As of Cordova 2.0, Plugins can no longer directly 
access the
     methods exist on the `Context`, so both `getContext()` and
     `getActivity()` can return the required object.
     
    +## Android Permissions
    +
    +Android permissions until recently have been handled at install-time 
instead
    +of runtime.  These permissions are required to be declared on an 
application that uses
    +the permissions, and these permissions need to be added to the Android 
Manifest.  This can be
    +accomplished by using the config.xml to inject these permissions in the 
AndroidManifest.xml file.
    +The example below uses the Contacts permission.
    +
    +        <config-file target="AndroidManifest.xml" parent="/*">
    +            <uses-permission 
android:name="android.permission.READ_CONTACTS" />
    +        </config-file>
    +
    +## Android Permissions (Cordova-Android 5.0.x and greater)
    +
    +Android 6.0 "Marshmallow" introduced a new permissions model where
    +the user can turn on and off permissions as necessary.  This means that
    +applications must handle these permission changes to be future-proof, which
    +was the focus of the Cordova-Android 5.0 release.
    +
    +The permissions that need to be handled at runtime can be found in the 
Android Developer
    +documentation here.
    +
    +As far as a plugin is concerned, the permission can be requested by 
calling the permission method, which signature is as follows:
    +
    +        cordova.reqquestPermission(CordovaPlugin plugin, int requestCode, 
String permission);
    +
    +To cut down on verbosity, it's standard practice to assign this to a local 
static variable:
    +
    +    public static final String READ = Manifest.permission.READ_CONTACTS;
    +
    +
    +Then, in the exec method, the permission should be checked:
    +
    +            if(cordova.hasPermission(READ)) {
    +                search(executeArgs);
    +            }
    +            else
    +            {
    +                getReadPermission(SEARCH_REQ_CODE);
    --- End diff --
    
    Not clear here if `SEARCH_REQ_CODE` is an Android constant or something 
defined by the plugin author. From the code further down, it seems like it's 
author-defined in the plugin?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to