html - cordova camera capture using javascript -
i'd capture image using phones camera, have installed plugin 'org.apache.cordova.camera' , permissions should come automatically, though, checked, , did.
from understand, need button calling javascript
<button id="photo" class="camera-control" onclick="capturephoto()">capture photo</button>
and ofc, script itself
function capturephoto(){ navigator.camera.getpicture(camerasuccess,null{sourcetype:1,quality:60}); }
i doing android (using htc 1 m8), missing super obvious?
it seems when success/error callbacks not defined , passed getpicture method cordova camera plugin works not expected reason in js-file not checked whether successcallback , errorcallback passed , not undefined. if there no callbacks passed plugin might not able start calling native camera on platform(android,ios, wp8) because wherever success/error callback used within native code plugin not able call 1 or either of them.
an example of android:
on android there method:
public void failpicture(string err) { this.callbackcontext.error(err); }
that used call passed error callback if instance taken picture(bitmap) not compressed using jpeg-image compression processing.
defining both success/error callbacks every plugin should done because if there has been error thrown within native environment/code webview-app can notified error , presenting appropriate ui/message user.
hope helps.
Comments
Post a Comment