How do i multi select images in the Gallery and send there URL to my activity?

5279 views
Skip to first unread message
Message has been deleted

Hans-Erik

unread,
Dec 22, 2010, 1:26:19 PM12/22/10
to Android Developers
hi
In the gallery I have added my Item to the share menu. But i can only
get one image and making my Activity start. This code give me the URL
for one image. Is it possible to set up the Gallery or the share menu
so that user can select one or many pictures?

if (Intent.ACTION_SEND.equals(action))
{ if extras.containsKey(Intent.EXTRA_STREAM))
{ Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
Toast toast = Toast.makeText(this, "path:
"+getRealPathFromURI(uri),
Toast.LENGTH_SHORT); toast.show();
return;
} else if
(extras.containsKey(Intent.EXTRA_TEXT)) {
}

}

public String getRealPathFromURI(Uri contentUri) { String[] proj =
{
MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri,proj, null, null, null);
int column_index =
cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}

<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" /
<data android:mimeType="image/*" />
</intent-filter>

Mark Murphy

unread,
Dec 22, 2010, 2:17:08 PM12/22/10
to android-d...@googlegroups.com
ACTION_SEND only supports sending one item.

On Wed, Dec 22, 2010 at 12:45 PM, Hans-Erik <eriks...@gmail.com> wrote:
> hi
> In the gallery I have added my Item to the share menu. But i can only
> get one image and making my Activity start. This code give me the URL
> for one image. Is it possible to set up the Gallery or the share menu
> so that user can select one or many pictures?
>
> if (Intent.ACTION_SEND.equals(action))
>        { if extras.containsKey(Intent.EXTRA_STREAM))

>                { Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM); //path
> to image


>                                Toast toast = Toast.makeText(this, "path: "+
> getRealPathFromURI(uri),
>                                Toast.LENGTH_SHORT); toast.show();
>                                return;
>                } else if
>                        (extras.containsKey(Intent.EXTRA_TEXT)) {
> }
>
> } public String getRealPathFromURI(Uri contentUri) { String[] proj =
> {
>                MediaStore.Images.Media.DATA }; Cursor cursor =
> managedQuery(contentUri,
>                proj, null, null, null); int column_index =
>                cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
>                cursor.moveToFirst(); return cursor.getString(column_index);
> }
>
>                <intent-filter>
>                        <action android:name="android.intent.action.SEND" />
>                        <category android:name="android.intent.category.DEFAULT" /
>>
>                    <data android:mimeType="image/*" />
>                </intent-filter>
>

> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-d...@googlegroups.com
> To unsubscribe from this group, send email to
> android-develop...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
Available!

Hans-Erik

unread,
Dec 22, 2010, 2:31:44 PM12/22/10
to Android Developers

On 22 Dec, 20:17, Mark Murphy <mmur...@commonsware.com> wrote:
> ACTION_SEND only supports sending one item.

Thanks for your reply
Do you know any other way to do this?
My Activity is dormant and awaken by the user selecting images.
There has to be another way to do this right?

bruce

unread,
Dec 22, 2010, 2:48:16 PM12/22/10
to Android Developers
What you want is ACTION_SEND_MULTIPLE. You will receive a set of
Uris.

Something like
if (Intent.ACTION_SEND_MULTIPLE.equals(action))
&& Intent.hasExtra(Intent.EXTRA_STREAM)) {
ArrayList<Parcelable> list =
intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
for (Parcelable p : list) {
Uri uri = (Uri) p;
/// do something with it.
}
}
Just add android.intent.action.SEND_MULTIPLE to your manifest.

Bruce

Hans-Erik

unread,
Dec 22, 2010, 2:58:22 PM12/22/10
to Android Developers

On 22 Dec, 20:48, bruce <palant...@gmail.com> wrote:
> What you want is ACTION_SEND_MULTIPLE. You will receive a set of
> Uris.

Thanks Bruce!
Coming from Java, Any book you can recommend learning android
infrastructure?
Reply all
Reply to author
Forward
0 new messages