Created
August 22, 2018 09:34
-
-
Save ssaurel/5ad7b20a7ee721f9465d1b880ddff958 to your computer and use it in GitHub Desktop.
Build list of permissions to request for the GPS Tutorial on the SSaurel's Blog
This file contains 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 characters
private ArrayList<String> permissionsToRequest(ArrayList<String> wantedPermissions) { | |
ArrayList<String> result = new ArrayList<>(); | |
for (String perm : wantedPermissions) { | |
if (!hasPermission(perm)) { | |
result.add(perm); | |
} | |
} | |
return result; | |
} | |
private boolean hasPermission(String permission) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
return checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment