Created
June 15, 2015 02:50
-
-
Save chap19150/0b0df56c3a347409056d to your computer and use it in GitHub Desktop.
Revisions
-
chap19150 created this gist
Jun 15, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ private static final int PERMISSIONS_REQUEST_READ_CONTACTS = 1; private static String[] PERMISSIONS_CONTACT = {Manifest.permission.READ_CONTACTS} if (checkSelfPermission(PERMISSIONS_CONTACT)) { Log.i(TAG, "Contact permissions have already been granted. Displaying contact details."); } else { Log.i(TAG, "Contact permissions has NOT been granted. Requesting permission."); requestPermissions(PERMISSIONS_CONTACT, PERMISSIONS_REQUEST_READ_CONTACTS); } … @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { case PERMISSIONS_REQUEST_READ_CONTACTS: { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // permission was granted, yay! do the // calendar task you need to do. Log.d(TAG, "permission granted"); } else { // permission denied, boo! Disable the // functionality that depends on this permission. Log.d(TAG, "permission denied"); } return; } } }