Skip to content Skip to sidebar Skip to footer

Receiving An Action_send Intent From The Gallery

I am trying to receive an image from the Android Gallery via an ACTION_SEND intent. I have set the proper intent filters and the Gallery opens my app. Now I want to know how to get

Solution 1:

Found this in the Picasa source. It gives the proper path of the image.

Intentintent= getIntent();
    if (Intent.ACTION_SEND.equals(intent.getAction())) {
        Bundleextras= intent.getExtras();
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            Uriuri= (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            Stringscheme= uri.getScheme();
            if (scheme.equals("content")) {
                StringmimeType= intent.getType();
                ContentResolvercontentResolver= getContentResolver();
                Cursorcursor= contentResolver.query(uri, null, null, null, null);
                cursor.moveToFirst();
                StringfilePath= cursor.getString(cursor.getColumnIndexOrThrow(Images.Media.DATA));

Solution 2:

Not sure about the SEND intent, but when handling returns from PICK intents to the MediaStore for a photo, it goes something like:

UriselectedImage= intent.getData();
    AssetFileDescriptorfd= getContentResolver()
            .openAssetFileDescriptor(selectedImage, "r");
    FileInputStreams= fd.createInputStream();
    // your image data processing code here

Be careful though - you can be working with 5+ megapixel files, which can be quite large (especially if you're uncompressing them to bitmaps to process), and your memory is pretty limited.

Post a Comment for "Receiving An Action_send Intent From The Gallery"