appcelerator titanium android camera native capture photo -
i working on cross-platform mobile app using appcelerator titanium alloy. code below opens native camera functionality , works fine on apple devices. on android devices, camera opens button take picture disabled (greyed out). buttons taking video or changing camera settings work fine, take picture button not working. ideas? in advance
the code below called on click of takepic button open camera
takepic.addeventlistener('click', function(e) { var win = titanium.ui.createwindow({ //open camera }); titanium.media.showcamera({ success:function(event){ ti.api.debug('our type was: '+event.mediatpe); if(event.mediatype == ti.media.media_type_photo){ ***win = titanium.ui.currentwindow; if(osname == "android"){ win.open(); }*** try { var image_name = "siteing.jpg"; var fileimage = titanium.filesystem.getfile(titanium.filesystem.applicationdatadirectory, image_name); fileimage.write(event.media); ti.api.log(event.media); picurl = fileimage;//event.media; picraw = event.media; //raw bytes of picture save database pictureset = true; $.videobutton.enabled = false; $.videobutton.backgroundcolor = "#dddddd"; //$.audiobutton.enabled = false; format = "picture"; $.savepic.show(); } catch(e){ alert("an error:" + e.message); } } else { var alert = createerroralert({text:"an error occured getting media. please check file size , format , try again."}); $.yeslatlon.add(alert); alert.show(); } if(osname == "android"){ win.open(); } }, cancel:function(){ //called when user cancels taking picture if(osname == "android"){ //win.close(); } }, error:function(error){ //called when there's error var = titanium.ui.createalertdialog({title:'camera'}); if(error.code == titanium.media.no_camera){ a.setmessage('please run test on device'); } else { a.setmessage('unexpected error: ' + error.code); } a.show(); }, savetophotogallery:true, //allowediting , mediatypes ios-only settings allowediting:true, mediatypes:[ti.media.media_type_video, ti.media.media_type_photo] }); alert.hide(); $.yeslatlon.removeeventlistener('androidback', arguments.callee); });
Comments
Post a Comment