How can I update the Android Gallery after a photo? -


for university i've develop application on android face detections. i've save various photo on gallery. problem after saving photo, gallery not update. more precisely, if delete directory i'm going save image, open application , shoot photo, going gallery , after "update" see photo. once have directory, if take new picture, did not overwrite old one.

online i've found this:

    sendbroadcast(new intent(intent.action_media_mounted,uri.parse("file://" + environment.getexternalstoragedirectory()))); 

...but doesn't work!

this code:

    .     .     .       imagebutton buttonpicture = (imagebutton) findviewbyid(r.id.camera_surface_button);                         buttonpicture.setonclicklistener(new onclicklistener(){                                 public void onclick(view v) {                                         mcamera.takepicture(null, null, jpegcallback);                                          //file file = new file(savedpath, "ing.jpg");                                         sendbroadcast(new         intent(intent.action_media_mounted,uri.parse("file://" +     environment.getexternalstoragedirectory())));                                  }                         });      .      .      .      .      picturecallback jpegcallback = new picturecallback() {                 public void onpicturetaken(byte[] _data, camera _camera) {                         imagesfolder = new file(environment.getexternalstoragepublicdirectory(environment.directory_pictures), "/ttrprova");                         imagesfolder.mkdirs();                         string filename = "image3.jpg";                          file output = new file(imagesfolder, filename);                          textview1.settext("-----sono nella callback-----");                          uri outputfileuri = uri.fromfile(output);                         string filepath = outputfileuri.getpath();                         file file= new file(filepath);                          try {                             fileoutputstream fos = new fileoutputstream(file, true);                             fos.write(_data);                             fos.close();                          } catch (filenotfoundexception e) {                             // todo auto-generated catch block                             textview1.settext("-----filenotfoundexception-----");                             e.printstacktrace();                         } catch (ioexception e) {                             // todo auto-generated catch block                             textview1.settext("-----ioexception-----");                             e.printstacktrace();                         }                          //riparte la preview della camera                         //mcamera.startpreview();                    }     }; 

hope in help. bye

you can force mediascanner add specific file (or let know deleted or modified)

sendbroadcast(new intent(intent.action_media_scanner_scan_file, uri.fromfile(mynewfile))); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -