Is it possible to share the code! I am creating also such application where i wanted to take a picture and upload this picture to my website! Can I take a picture with the emulator?
Thank you, Wouter On May 8, 12:30 am, Anna PS <annapowellsm...@googlemail.com> wrote: > > > 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? > > > Use regular Java I/O to open the stream, rather than openFileInput(). > > Environment.getExternalStorageDirectory() will return you a File pointing > > to the SD card, which you can use as the basis for building your path. > > Thanks. For reference, the working code is: > > FileInputStream fstream = null; > fstream = new FileInputStream > (Environment.getExternalStorageDirectory() + "/" + "photo.jpg"); > bmp = BitmapFactory.decodeStream(fstream); > iv.setImageBitmap(bmp); > > > > 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? > > > Use the same stream as above, and read it in: > > >http://www.exampledepot.com/egs/java.io/File2ByteArray.html > > Works perfectly - thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---