I've hacked around with the code from 
http://mobile.photoshop.com/android/developers.html
to get about half way there.  This code brings up the Gallery and when
an image is selected, it opens PhotoShop Express to edit the image.
I've hacked the intent that to point to the Gallery viewer (the
fullscreen view of an image, not the thumbnails) by replacing
ACTION_EDIT with ACTION_VIEW.

Now, this still grabs the images from the SD card; I'd like to grab
them from my drawable resources embedded in the app.  Thoughts?

package com.adobe.psmobile.editor.launcherappone;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

// LauncherOneMain: Main activity for sample application that uses
Photoshop Express Editor
public class LauncherOneMain extends Activity
{
    private static final int SELECT_IMAGE = 0; // selector for image
gallery call
    private static final int LAUNCH_EDITOR = 1; // selector for editor
launch call

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // launch the image picker
        launchImagePicker();

    }

    // Launches the image picker.
    public void launchImagePicker()
    {
        try
        {
            // This opens the Android Gallery or a similar activity
            // that displays the images on the Android devices's SD
card.
            // The selected image is returned with a call to
onActivityResult
            // with the request code SELECT_IMAGE
            startActivityForResult(new Intent(Intent.ACTION_PICK,
 
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI),
              SELECT_IMAGE);
        }
        catch (ActivityNotFoundException e)
        {
            // No activity found that handles Intent.ACTION_PICK
        }
    }

    /**
    * onActivityResult: Called when an activity you launched exits,
    * giving you the requestCode you started it with along with
    * the resultCode it returned, and any additional returned data.
    * The resultCode will be RESULT_CANCELED if the activity
explicitly
    * returned that, didn't return any result, or
    * abnormally terminated during its operation.
    */
    @Override
    public void onActivityResult(int requestCode, int resultCode,
Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == SELECT_IMAGE)
        {
            if (resultCode == Activity.RESULT_OK)
            {
                // get the Uri for the selected image
                Uri selectedImage = data.getData();

                // create an Intent to launch activity that
                // supports ACTION_EDIT for
                // the selected image. Photoshop Express Editor
                // handles such intent
                Intent launchEditor = new Intent();
                launchEditor.setAction(Intent.ACTION_EDIT);
                launchEditor.setDataAndType(selectedImage,
data.getType());

                try
                {
                    // start the activity. Result will be returned
in                     // onActivityResult call with
                    // requestCode LAUNCH_EDITOR
                    startActivityForResult(launchEditor,
LAUNCH_EDITOR);
                }
                catch (ActivityNotFoundException e)
                {
                    // No activity found. Correct version of Photoshop
Express
                    // Editor not installed.
                    Toast myToast = Toast.makeText(this,
                    new String("Failed to Launch Editor. Please make
sure
                      Photoshop Express 1.1 or above is installed."),
                    Toast.LENGTH_SHORT);
                    myToast.show();
                }
            }
        }
        else if (requestCode == LAUNCH_EDITOR)
        {
            // returned from editor

            String resultStr = null;

            if (resultCode == Activity.RESULT_OK)
            {
                // Editor operation returned after saving the image.
                // Get the Uri for the newly edited image that was
saved.
                 Uri savedImage = data.getData();
                resultStr = new String("Editor saved image to Uri: ")
+
                  savedImage.toString();
            }
            else
            {
                // Editor operation canceled by user
                resultStr = new String("Edit operation canceled.");
            }

            // display Toast with message
            Toast myToast = Toast.makeText(this, resultStr,
Toast.LENGTH_SHORT);
            myToast.show();

            // now that the editing operation has completed,
            // launch the image picker again
            launchImagePicker();
        }
    }

}

On Sep 1, 9:44 am, Christopher <christopher.t.mor...@gmail.com> wrote:
> I have an app with locally stored .jpg files.  I would like to be able
> to send the images (1 at a time, on user interaction) to the Gallery
> app's activity using an explicit intent.
>
> Any thoughts?

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

Reply via email to