What are you actually trying to achieve here? Gallery generally expects the things it operates on to be in the media provider. If they aren't... well, maybe you can get it to work, but there is a good chance you are going to have inconsistent behavior between different platform versions and devices.
On Wed, Sep 1, 2010 at 6:29 PM, Christopher <[email protected]>wrote: > 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 <[email protected]> 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 [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

