Skip to content

Instantly share code, notes, and snippets.

@ahmed-shehataa
Created August 9, 2020 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmed-shehataa/fcd6345876e351fc2d6fecf976900a14 to your computer and use it in GitHub Desktop.
Save ahmed-shehataa/fcd6345876e351fc2d6fecf976900a14 to your computer and use it in GitHub Desktop.
//Grant run time permission
int permission = ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission == PackageManager.PERMISSION_GRANTED) {
} else {
Snackbar.make(getView(), "Please allow access to your storage", Snackbar.LENGTH_LONG)
.setAction("Allow", view -> ActivityCompat.requestPermissions(getActivity(), new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE
}, 0)).show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment