Is there a way to use intent.setType()
and supply multiple broad types (like images and video)?
I am using an ACTION_GET_CONTENT
. It seems to be working with just comma-separated types.
MIME stands for Multipurpose Internet Mail Extensions, and is commonly used to define the data-type when transferring data across the internet. For intance, "application/json" or "application/pdf" or "text/plain".
To get the data type of a shared file given its content URI, the client app calls ContentResolver. getType() . This method returns the file's MIME type. By default, a FileProvider determines the file's MIME type from its filename extension.
MIME types enable browsers to recognize the filetype of a file which has been sent via HTTP by the webserver. As a result the browser is able to choose a suitable displaying method. Common MIME types are for example text/html for html-files or image/jpeg for jpeg-files.
In Android 4.4 when using the Storage Access Framework you can use the EXTRA_MIME_TYPES
to pass multiple mime types.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); String[] mimetypes = {"image/*", "video/*"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); startActivityForResult(intent, REQUEST_CODE_OPEN);
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