javascript - Retrieving and displaying photo with phonegap works in emulator but not on my phone -
i using phongap api take photo , display in app. works fine in emulator (using ripple extension in chrome) doesn't work on phone or tablet (both android). got ideas why?
edit: i've established taking , returning photo ok, , creating canvas, not drawing image canvas reason.
edit 2: resolved after reading this: how can load image onto html5 canvas using phonegap. later features not working . . . in case looks problem wasn't permissions.
// called 'take photo' button function takephoto() { // take picture using device camera , retrieve image base64-encoded string. if //camera unavailable offer option retrieve file navigator.camera.getpicture(onsuccess, onfail, { quality: 50, destinationtype: camera.destinationtype.data_url } ); } // displays image on screen function onsuccess (imagedata) { alert("hello " + imagedata.length); //added check if making ///this point var image = document.getelementbyid("image"); image.src = imagedata; var c=document.getelementbyid("mycanvas"); var ctx=c.getcontext("2d"); ctx.drawimage(image,0,0,c.width,c.height); } function onfail(message) { alert("failed because: " + message); }
paste on andorid confing.xml <feature name="http://api.phonegap.com/1.0/device" /> <feature name="http://api.phonegap.com/1.0/battery"/> <feature name="http://api.phonegap.com/1.0/camera"/> <feature name="http://api.phonegap.com/1.0/contacts"/> <feature name="http://api.phonegap.com/1.0/file"/> <feature name="http://api.phonegap.com/1.0/geolocation"/> <feature name="http://api.phonegap.com/1.0/media"/> <feature name="http://api.phonegap.com/1.0/network"/> <feature name="http://api.phonegap.com/1.0/notification"/> paste on androidmanifest.xml uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-sdk android:minsdkversion="7"/> <activity android:configchanges="orientation|keyboardhidden" /> <uses-permission android:name="android.permission.camera" /> <uses-permission android:name="android.permission.write_external_storage" /> <permission android:name="android.permission.access_network_state" />
Comments
Post a Comment