Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple MIME types in Android

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.

like image 489
James Avatar asked Nov 08 '09 21:11

James


People also ask

What is MIME type of data in Android?

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".

How can I get MIME type in Android?

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.

What is MIME type give examples?

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.


1 Answers

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); 
like image 85
Fred Avatar answered Oct 13 '22 04:10

Fred