Photoshop.com « Back to Photoshop Express for Android

ADOBE® PHOTOSHOP® EXPRESS FOR ANDROID™

our editor +
your app


Use the Photoshop Express editor in your own Android application

Developer Documentation

Photoshop Express editor integration steps

Any application can use the Photoshop Express 1.1 editor for editing images on Android phones. To get started, you first need to install the Photoshop Express application on your Android device. See the "Get Photoshop Express" item in the sidebar to the right, or search for "Photoshop Express" in the "Market" application on your Android device.

The Photoshop Express editor is available as an activity that handles actions of type Intent.ACTION_EDIT, for image content that has data of mime-type image/*.

Following is the code snippet for launching the Photoshop Express editor from an activity within your Android application:

// code inside an Activity method
Uri imageToEditUri = … // uri of image to edit
String imageToEditMimeType = … // must be of type “image/*”
Intent launchEditor = new Intent();
launchEditor.setAction(Intent.ACTION_EDIT);
launchEditor.setDataAndType(imageToEditUri, imageToEditMimeType);

try
{
    // start the editor activity
    startActivityForResult(launchEditor, LAUNCH_EDITOR);
}
catch (ActivityNotFoundException e)
{
    // Handle error condition. Correct version of
    // Photoshop Express not installed?
}

To obtain the edit operation result, override onActivityResult in your activity and check the resultCode for your request. If the user has edited and saved the image, the result code returned is RESULT_OK. In this case, the URI for the saved image can be obtained using the Intent.getData() call. Otherwise, if the user cancels the editing operation, RESULT_CANCELED is returned.

Sample code for onActivityResult is shown below:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == LAUNCH_EDITOR)
    {
        if (resultCode == Activity.RESULT_OK)
        {
            Uri savedImage = data.getData();
            // savedImage is the Uri for the newly created
            // edited version of the original image.
        }
        else
        {
            // Edit Operation canceled by user
        }
    }
}


Here is a complete code listing for an Android application that incorporates the Photoshop Express editor.

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();
        }
    }

}