camera - Android name image programatically -


i want give custom name image captured through camera programatically. have used snippets of codes given here how control/save images took android camera programmatically? still doesn't work , image stored default name. idea why? i'd grateful.

public class mainactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_main);     button camerabutton = (button) findviewbyid(r.id.takepicture);      camerabutton.setonclicklistener( new onclicklistener(){          public void onclick(view v ){             //intent intent = new intent("android.media.action.image_capture");             //startactivityforresult(intent,0);             intent intent = new intent(mediastore.action_image_capture);              uri muri = uri.fromfile(new file(environment.getexternalstoragedirectory(),                             "pic_"+ string.valueof(system.currenttimemillis()) + ".jpg"));              intent.putextra(android.provider.mediastore.extra_output, muri);             startactivityforresult(intent,0);         }     }); } 

}

you can try follows...

    intent takepictureintent = new intent(mediastore.action_image_capture);      string fullpath = "";     file imagefile = null;     string timestamp = new simpledateformat("yyyymmdd_hhmmss").format(new date());     string picturename = "img_" + timestamp + ".jpg";      fullpath = environment.getexternalstoragedirectory() + "/imagefolder/" + picturename;      file dir = new file(environment.getexternalstoragedirectory() + "/imagefolder/");     dir.mkdirs();      imagefile = new file(fullpath);     takepictureintent.putextra(mediastore.extra_output, uri.fromfile(imagefile));     startactivityforresult(takepictureintent, 1); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -