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?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

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.

Solution 2

The modern action is ACTION_GET_CONTENT, which is much better supported,

ACTION_PICK :

Activity Action: Pick an item from the data, returning what was selected.

Input: getData() is URI containing a directory of data (vnd.android.cursor.dir/*) from which to pick an item.

Output: The URI of the item that was picked.

Constant Value: "android.intent.action.PICK"


Difference :-

Activity Action: Allow the user to select a particular kind of data and return it.

This is different than ACTION_PICK in that here we just say what kind of data is desired, not a URI of existing data from which the user can pick.

A ACTION_GET_CONTENT could allow the user to create the data as it runs (for example taking a picture or recording a sound), let them browse over the web and download the desired data, etc.

Reference http://developer.android.com/reference/android/content/Intent.html#ACTION_GET_CONTENT

Solution 3

 public static final String ACTION_GET_CONTENT

Added in API level 1

Activity Action: Allow the user to select a
particular kind of data and return it. This is different than
ACTION_PICK in that here we just say what kind of data is desired, not
a URI of existing data from which the user can pick. A
ACTION_GET_CONTENT could allow the user to create the data as it runs
(for example taking a picture or recording a sound), let them browse
over the web and download the desired data, etc.

via http://developer.android.com/reference/android/content/Intent.html#ACTION_GET_CONTENT

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply