generating a camera event

generating a camera event

hi there,

I'm writing a cross-platform App with XDK new and am trying to generate an event to turn the camera off, but am having no luck.

The code is something like this:, false, "jpg");  turn camera on

    // set a timer using an interval 
    timerHandle = setInterval(function(){cameraStop();}, 10000);   // give the user 10s to take a picture


// if they haven't taken the picture after 10s, turn off the camera by generating a camera event


function cameraStop() {
    clearInterval(timerHandle);    // stop the timer

    var stopCameraEvent = document.createEvent("Events"); 

   stopCameraEvent.initEvent("", true, false);  // event type, bubbling and non-cancellable




Does anyone have any experience with turning off the camera and/or generating events from within XDK?  Please let me know any pointers, solutions, tips...  


thank you,





4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

to be obvious, a comment was forgotten in this entry (but not in the code) at:, false, "jpg");  turn camera on

should be:, false, "jpg");  // turn camera on



Best Reply

I don't think it's possible because what you've done when you initiate use of the camera is fire an "intent" that starts up the default camera application on the device. When the user exits from the camera application it returns you to the app that cause the camera app to start. In other words, the camera app is not part of your app, it is providing a service to your app and has control of the UI while it provides that service.

That's a shame.  I guess I may have to go "native" on this one.

Thanks for your help Paul,



Leave a Comment

Please sign in to add a comment. Not a member? Join today