Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created April 19, 2015 12:03
Show Gist options
  • Save defHLT/b356474e3eb2624a08d5 to your computer and use it in GitHub Desktop.
Save defHLT/b356474e3eb2624a08d5 to your computer and use it in GitHub Desktop.
public void invokePicker(Integer requestCode) {
Intent intentGetContent = new Intent(Intent.ACTION_GET_CONTENT,
MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intentGetContent.setType("image/*");
final PackageManager pm = getPackageManager();
final Intent i = new Intent(intentGetContent);
final List list = pm.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0) {
startActivityForResult(intentGetContent, requestCode);
} else {
Intent intentPick = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intentPick.setType("image/*");
startActivityForResult(Intent.createChooser(intentPick, "Complete action using"),
requestCode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment