Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android pick intent

I am trying to pick a file with any of these 3 mime types, and it doesn't seem to work

Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*, video/*, audio/*");

Can someone suggest how I can do it ?

like image 951
BurunduK Avatar asked Nov 13 '22 02:11

BurunduK


1 Answers

Write below code instead of your code, it may help you.

private static final int PICTURE = 0;
private static final int VIDEO = 1;
private static final int AUDIO = 2; 


Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
String title = GET_PICTURE;

if (this.mediaType == PICTURE) {
    photoPickerIntent.setType("image/*");
    title = "GET_PICTURE";  
}else if (this.mediaType == VIDEO) {
    photoPickerIntent.setType("video/*");     
    title = "GET_VIDEO";
}else if (this.mediaType == AUDIO) {
    photoPickerIntent.setType("audio/*");     
    title = "GET_AUDIO";
}

And Use below links for reference.

Pick Intent Example

like image 114
Dipak Keshariya Avatar answered Nov 16 '22 02:11

Dipak Keshariya