Android-Thumbnail showing correct picture but Original showing different Picture -


i using camera api in app now, have 2 issues in app:

  1. i saving image folder in sdcard, problem after capturing , looking folder thumbnail showing correct image after selecting photo display previous taken photo in fullscreen. every time saving photo in same name each time overwrite previous image.

  2. second issue using params.setflashmode(camera.parameters.flash_mode_torch) when press button flash doesn't turn of still remains turn on.i have tried camera.release() in surfacedestroyed(surfaceholder holder)

you can try this, rough code give direction.

bitmap bmp; public void oncreate(bundle savedinstancestate)    {        super.oncreate(savedinstancestate);     //fullscreen     requestwindowfeature(window.feature_no_title);    getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen);     //set view    setcontentview(r.layout.main);     preview = new preview(this); // <3>    rootlayout = ((framelayout) findviewbyid(r.id.preview));    rootlayout.addview(preview);    progress = new progressdialog(this);    imageview rectview = (imageview) findviewbyid(r.id.imageview1);    rectview.bringtofront();     buttonclick = (button) findviewbyid(r.id.buttonclick);    buttonclick.setonclicklistener(new onclicklistener() {        @override        public void onclick(view v) { // <5>            new connectasynctask.execute();            buttonclick.setenabled(false);        }    }); } public void comparison(byte[] data,camera camera) throws ioexception {    string path=getstring(r.string._sdcard_path);//<string name="_sdcard_path">/sdcard/images/</string>     string extension=getstring(r.string._sdcard_d_jpg);// <string name="_sdcard_d_jpg">.jpg</string>    /*string srcpath1="/sdcard/images/";    file f=new file(srcpath1);    int h=0,count=0;    string [] cnt=f.list();        while(h<cnt.length)        {            count++;             h++;        }extension=count+extension;*/    bytearrayoutputstream stream=null;    fileoutputstream outstream = null;    bmp =bitmapfactory.decodebytearray(data, 0, data.length);     // int i=0,x=50;         stream=new bytearrayoutputstream();         tembitmap.compress(bitmap.compressformat.jpeg,100, stream);        path+=string.format(                getstring(r.string._sdcard_d_jpg),                system.currenttimemillis());        outstream = new fileoutputstream(path+extension); // <9>        outstream.write(stream.tobytearray());        outstream.close();                  //rs="place strip correctly!!";            toast.maketext(getapplicationcontext(),"test", toast.length_long).show();    }  // called when shutter opened shuttercallback shuttercallback = new shuttercallback() { // <6>    @override    public void onshutter() {        log.d(tag, "onshutter'd");    } };  // handles data raw picture picturecallback rawcallback = new picturecallback() { // <7>    @override    public void onpicturetaken(byte[] data, camera camera) {        log.d(tag, "onpicturetaken - raw");    } };  // handles data jpeg picture picturecallback jpegcallback = new picturecallback() { // <8>    @override    public void onpicturetaken(byte[] data, camera camera) {        try {            comparison(data,camera);//new connectasynctask(data, camera).execute();        } catch (ioexception e) {            // todo auto-generated catch block            e.printstacktrace();        }     } };    void showprogress() {    //toast.maketext(getapplicationcontext()," picture saving please wait..!!", toast.length_short).show();    progress.setindeterminate(true);    progress.setcancelable(false);    progress.setcanceledontouchoutside(false);    progress.show();  }   private class connectasynctask extends asynctask<void, void, string> {    // private progressdialog progressdialog;     connectasynctask(byte[] data, camera camera) throws ioexception {        //saveimagetosd(data, camera);         //toast.maketext(getapplicationcontext(), stat, toast.length_long).show();    }     @override    protected void onpreexecute() {        // todo auto-generated method stub        super.onpreexecute();        showprogress();    }     @override    protected string doinbackground(void... params) {         preview.camera.takepicture(shuttercallback, rawcallback, jpegcallback);        comparison(data,camera);        return "";    }     @override    protected void onpostexecute(string result) {        super.onpostexecute(result);        progress.dismiss();        imageview rectview = (imageview) findviewbyid(r.id.imageview1);        rectview.setimagebitmap(bmp);     }  } @override protected void ondestroy() {     parameters params = camera.getparameters();         params.setflashmode(camera.parameters.flash_mode_off);        camera.setparameters(params);        if(camera!=null){            camera.stoppreview();            camera.release();                camera = null;        } } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -