Hi Mark, I've used the camera code from the Advanced Android book and it's working nicely. Thank you.
Just a couple of basic questions (for Mark, or anyone else) about the retrieval/URI issue, both assuming the photo is saved on the SD card as "photo.jpg". 1. Thumbnail display. When I go back to the first screen of the application, I want to show an ImageView of the jpeg that the user has just taken. Current code, which doesn't work because it's not looking in the SD card: bmp = BitmapFactory.decodeStream(openFileInput("photo.jpg")); iv.setImageBitmap(bmp); This gives the error: "java.IO.FileNotFoundException: /data/data/ com.android.filename/files/photo.jpg". How can I ask BitmapFactory to look in the SD card for the jpeg? 2. Uploading the jpeg - I would like to convert the jpeg to a byte[] array, to upload it as part of a FilePart. Again, how can I retrieve the jpeg from the SD card to do this? My previous code used a media URI to retrieve a bitmap, compress it into a jpeg and write it to a byte array. This worked, but now I need to replace this with a reference to "photo.jpg": Bitmap bitmap; ByteArrayOutputStream imageByteStream; byte[] imageByteArray = null; bitmap = android.provider.MediaStore.Images.Media.getBitmap (getContentResolver(), uri); imageByteStream = new ByteArrayOutputStream(); if (bitmap == null) { Log.d(LOG_TAG, "No bitmap"); } // Compress bmp to jpg, write to the byte output stream bitmap.compress(Bitmap.CompressFormat.JPEG, 80, imageByteStream); // Turn the byte stream into a byte array imageByteArray = imageByteStream.toByteArray(); Thanks again, Anna On May 7, 1:14 am, Mark Murphy <mmur...@commonsware.com> wrote: > Anna PS wrote: > > What I don't know is what > > to launch when the user clicks on it. A modified version of the Camera > > class, or something like MediaStore.ACTION_IMAGE_CAPTURE? > > I haven't used the latter, so I can't comment on it. > > > I need to (a) display the photo as a thumbnail on the activity's home > > screen, and (b) upload the photo as part of a multipart message. > > > In both cases I need some way to refer back to the photo that the user > > has taken. I'm assuming the only way is via aURI? Is there another > > way? > > In terms of the thumbnail, you can either let Android scale it > automatically from a file or use Bitmap to scale it under your control > and hand the Bitmap to the ImageView. Neither of those requires aURI. > > I don't know how you intend to send the email and therefore what might > be required for it. > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://twitter.com/commonsguy > > Android App Developer Books:http://commonsware.com/books.html --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---