Search in sources :

Example 1 with NeedsPermission

use of permissions.dispatcher.NeedsPermission in project SimpleCropView by IsseiAoki.

the class MainFragment method pickImage.

@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
public void pickImage() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("image/*"), REQUEST_PICK_IMAGE);
    } else {
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("image/*");
        startActivityForResult(intent, REQUEST_SAF_PICK_IMAGE);
    }
}
Also used : Intent(android.content.Intent) NeedsPermission(permissions.dispatcher.NeedsPermission)

Aggregations

Intent (android.content.Intent)1 NeedsPermission (permissions.dispatcher.NeedsPermission)1