Wednesday, August 31, 2011

[android-developers] Re: Images captures via Camera api exits in the Sd card but not dispalyed in the galary

http://developer.android.com/reference/android/provider/MediaStore.Images.Media.html#insertImage(android.content.ContentResolver,
java.lang.String, java.lang.String, java.lang.String)

and don't use /sdcard directly
http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()

On Aug 30, 6:28 pm, chadnan gupta <cgupta.inte...@gmail.com> wrote:
> Hi..
>
> From last few days i m trying to develop an application in which
> takes multiple images(say 10 images ) , after a user clicks the start button
> I have successfully done that , but the problem which i m getting right now
> is that ,
>
> 1. the images which are captured are not listed(or say displayed) in
> the gallery
> 2.the images are listed in the "My Files->DCIM"(this is the path where i
> have stored my captured images ) , but when when i try to open any of the
> images it takes some time to open (10 secs)
>
> i think i have done some mistake while storing the images in the memory
> card
>
> the code for saving the images i like
>
> PictureCallback jpegCallback = new PictureCallback() {
> public void onPictureTaken(final byte[] data, Camera camera) {
>        new Thread(new Runnable() {
>      public void run() {
>       String state = Environment.getExternalStorageState();
>       if (Environment.MEDIA_MOUNTED.equals(state)) {
>     // We can read and write the media
>     mExternalStorageAvailable = mExternalStorageWriteable = true;} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
>
>     // We can only read the media
>     mExternalStorageAvailable = true;
>     mExternalStorageWriteable = false;} else {
>
>     // Something else is wrong. It may be one of many other states, but all
> we need
>     //  to know is we can neither read nor write
>     mExternalStorageAvailable = mExternalStorageWriteable = false;}
>
>      if(mExternalStorageWriteable)
> {
>       FileOutputStream outStream = null;
>       try {
>      path =String.format("/sdcard/DCIM/%d.jpg",
>                 System.currentTimeMillis());
>         // Write to SD Card
>         outStream = new FileOutputStream(path);
>         outStream.write(data);
>         outStream.close();
>
>       } catch (FileNotFoundException e) {
>         e.printStackTrace();
>       } catch (IOException e) {
>         e.printStackTrace();
>       } finally {
>       }}
>
>     }
>   }).start();
>
>  }
>
> };
>
> waiting for a solution

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment