android - Camera2 API picture taken wont show at gallery apps -


i have camera project , im using camera2 api link https://github.com/googlesamples/android-camera2basic

i can save picture taken file manager located @ dcim/camera example, when open gallery, wont show last picture.

can me?

one more question, want make camera can list: example, when open "line" , want take picture camera, want camera appears , can chosen.

this sample code tried saving picture custom path:

@override public void onactivitycreated(bundle savedinstancestate) {     super.onactivitycreated(savedinstancestate);     mfile = new file("/storage/emulated/0/dcim/camera", "pic.jpg");     int counter=1;     while (mfile.exists()) {         mfile = new file("/storage/emulated/0/dcim/camera", "pic" + string.format("%02d", counter) + ".jpg");         counter++;     }  } 

to show images in gallery need add contentvalues, in example: https://github.com/googlesamples/android-camera2basic found imagereader.onimageavailablelistener. code:

private final imagereader.onimageavailablelistener monimageavailablelistener = new imagereader.onimageavailablelistener() {     @override     public void onimageavailable(imagereader reader) {          // first path gallery , crate new album app         string pathd = environment.getexternalstoragedirectory() + "/" + environment.directory_dcim + "/";         file mediastoragedir = new file(pathd, "myalbum");         if (!mediastoragedir.exists()) {             if (!mediastoragedir.mkdirs()) {                 log.d("mycameraapp", "failed create directory");             }         }         /*second cut mfile = new file(getactivity().getexternalfilesdir(null), "pic.jpg");          onactivitycreated , add here new path album*/           string timestamp = new simpledateformat("yyyymmdd_hhmmss", locale.getdefault()).format(new date());         mfile = new file(mediastoragedir,"imagename"+"_"+ timestamp+".jpeg");          //then contentvalues         contentvalues values = new contentvalues();         values.put(mediastore.images.media.title, "imagename");         values.put(mediastore.images.media.date_taken, system.currenttimemillis());         values.put(mediastore.images.media.orientation, orientations.get(rotation));         values.put(mediastore.images.media.content_type,"image/jpeg");         values.put("_data", mfile.getabsolutepath());         contentresolver cr = getactivity().getcontentresolver();         cr.insert(mediastore.images.media.external_content_uri, values);        //this line in code        mbackgroundhandler.post(new imagesaver(reader.acquirenextimage(), mfile));      } }; 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -