Android Camera Video intent returns null URI -
i got updated android 4.3 , stock video camera started acting little weird whenever started intent app.
at first crash , "gallery stopped responding". after little while, able record video, clicking on done returned null uri app, made crash!
so set out testing 2.3.4 device same code. video app returned proper uri use on device. same code worked fine before got 4.3 (had 4.2.2 stock galaxy nexus)
here's activity null uri stock camera app of 4.3 works fine on devices 4.2.2 , less.
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button pick = (button) findviewbyid(r.id.button1); pick.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent takevideointent = new intent(mediastore.action_video_capture); startactivityforresult(takevideointent, 123); } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if(resultcode == result_ok){ if(requestcode == 123){ videoview videoview = (videoview) findviewbyid(r.id.videoview1); videoview.setvideouri(data.getdata()); log.d("video", "uri "+data.getdata()); } } super.onactivityresult(requestcode, resultcode, data); } } what do never happens? mean work differently other camera apps on different manufacturer devices?
i fixed changing video intent this:
intent intent = new intent(mediastore.action_video_capture); string fname = "videofilename.mp4"; file f = new file(fname); intent.putextra(mediastore.extra_output, uri.fromfile(f)); startactivityforresult(intent, camera_video_request); and in activity result got video file path follows:
file f = new file(environment.getexternalstoragedirectory().tostring()); (file temp : f.listfiles()) { if (temp.getname().equals("videofilename.mp4")) { f = temp; break; } } //f video file...
Comments
Post a Comment