I'd like the user to import a bunch of videos/photos into my app. This is the code I was using before:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setType("image/*,video/*");
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
The problem I'm having is that the above returns only Photos from the new Google Photos app. If I change the data type to 'video/*' only, the Photos app returns videos. This is for KitKat+
EDIT:
I've tried the following code - it works on some galleries but not with most and not Google Photos:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
if (AndroidHelper.isKitKatAndAbove()) {
Log.d(TAG, "Pick from gallery (KitKat+)");
String[] mimeTypes = {"image/*", "video/*"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
} else {
Log.d(TAG, "Pick from gallery (Compatibility)");
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
}
This is what I ended up doing:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
if (AndroidHelper.isKitKatAndAbove()) {
Log.d(TAG, "Pick from gallery (KitKat+)");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
} else {
Log.d(TAG, "Pick from gallery (Compatibility)");
activity.startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
}
Then when I get results, I check the type of the file. Seems to be working fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With