Issue
I am uploading selected files to server but I want to restrict users to pick only document files (.doc, .pdf, etc.) and image files.
For now my code is working for all files it fetches uri of all files.
How can I restrict users to pick only specific types of file?
Here is my code to pick any file.
Intent i=new Intent();
i.setType("*/*");
i.setAction(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(i, "abc"),requestCode);
Solution
Pass multiple MIME types separate with |
like
i.setType("image/*|application/pdf|audio/*");
or create an array of MIME types like
String[] mimetypes = {"image/*", "application/*|text/*"};
and pass it as
i.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
Answered By - Madhukar Hebbar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.