Accessing Android native gallery via an intent
<p>How can I get a user to select from the native gallery in Android, rather than other gallery-like applications such as ASTRO File Manager?</p>

<p>The following code gives a list of activities that can select an image:</p>

<pre><code>Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
List&lt;ResolveInfo&gt; infos = activity.getPackageManager().queryIntentActivities(intent, 0);
</code></pre>

<p>If I then do something like this:</p>

<pre><code>activity.startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_CHOOSE_IMAGE);
</code></pre>

<p>then if the user has more than one application that can act like a gallery (such as ASTRO File Manager), s/he is prompted to select one of them, with no "set as default" option.</p>

<p>I don't want the user to be prompted to choose between them each time, so I'd like to just use the native gallery.</p>

<p>The hacky code sample below uses a whitelist to test for known native gallery names:</p>

<pre><code>    for (ResolveInfo info : infos) {
        if (    0==info.activityInfo.name.compareTo("com.cooliris.media.Gallery")
            ||  0==info.activityInfo.name.compareTo("com.htc.album.CollectionsActivity")
        ) {
            // found the native gallery
            doSomethingWithNativeGallery();
        }
    }
</code></pre>

<p>Feels kinda dirty. Is there a better way? I suspect I'm missing something in my intent.</p>
