Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Intent.ACTION_GET_CONTENT and Intent.ACTION_PICK

I'm trying to let the user choose any image that they want on their device to use as a wallpaper in this wallpaper application I'm building. For some reason when I write:

Intent myIntent = new Intent(Intent.ACTION_PICK); myIntent.setType("image/*"); startActivityForResult(myIntent, 100); 

I go straight into the gallery, but when I write:

Intent myIntent = new Intent(Intent.ACTION_GET_CONTENT, null); myIntent.setType("image/*"); startActivityForResult(myIntent, 100); 

I get to choose from Gallery, or Google Drive. What is the best way to let the user choose what app to retrieve the picture from every time? Or why do those two different intent constants make a difference?

like image 531
EGHDK Avatar asked Jul 20 '13 18:07

EGHDK


People also ask

What is the difference between Action_pick and Action_get_content?

If you want the user to choose something based on MIME type, use ACTION_GET_CONTENT . If you have some specific collection (identified by a Uri ) that you want the user to pick from, use ACTION_PICK . In case of a tie, go with ACTION_GET_CONTENT .

What is Action_get_content Android?

If you have to pick a file in your app, but you don't want to implement your own file explorer; you can start a activity with intent of Intent. ACTION_GET_CONTENT. Android OS will choice a suitable app with such function for you.

What is ACTION PICK in android?

ACTION_PICK action is in buit in android and helps to pick an image item from a data source. We just need to provide the URI of the provider. Almost all core android applications (eg. Messaging, Gallery, Contacts etc) provide this facility. All you need is to set the intent action and the data.


1 Answers

Your first Intent is invalid. The protocol for ACTION_PICK requires you to supply a Uri indicating the collection you are picking from.

What is the best way to let the user choose what app to retrieve the picture from every time?

If you want the user to choose something based on MIME type, use ACTION_GET_CONTENT.

If you have some specific collection (identified by a Uri) that you want the user to pick from, use ACTION_PICK.

In case of a tie, go with ACTION_GET_CONTENT. While ACTION_PICK is not formally deprecated, Dianne Hackborn recommends ACTION_GET_CONTENT.

like image 53
CommonsWare Avatar answered Oct 05 '22 18:10

CommonsWare