Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Visitor
Posts: 1
Registered: ‎06-06-2009
My Device: Not Specified

WebWorks Camera access doesn't work

I have a WebWorks app and I want to use the camera API. I tried adding that functionality today and ran across a weird problem: the app never receives a callback because the user never leaves the camera app.

 

I added appropriate <access> element in the config, then tried this simple line:

 

blackberry.media.camera.takePicture(function () {alert(arguments);},
function () {alert('camera closed')}, function (e) {alert('error occured:'+e); });

 

 

when I run this, it goes to the camera app, where I can take, delete and view pictures, however the app never leaves the camera view and none of the callbacks are called. If I press the back button, the app simply quits. The API leads me to believe that after the user takes a picture, the camera view should close and the javascript callbacks are called with either the picture file name or an error.

 

I've tried this on a simulator only, is it a known issue there? 

Developer
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: WebWorks Camera access doesn't work

Hello martythemaniak,

 

I see that the problem is with your parameters on the takePicture success callback.

 

Please see the following code : 

blackberry.media.camera.takePicture(
  function () {alert(arguments);}, // should have been function(arguments) {alert(arguments);},
  function () {alert('camera closed')}, 
  function (e) {alert('error occured:'+e); }
);

 Hopefully that's just the problem.

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: WebWorks Camera access doesn't work

There's the additional problem that alerts will not fire while your app is in the background (which would stop javascript execution until the alert was dealt with). To test the camera app try modifying the dom on the success callback



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: WebWorks Camera access doesn't work

[ Edited ]

Jeff, slightly off-topic:


Are the JS alerts ignored and skipped while the app is in the background, or is everything after the alert ignored/blocked too?

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: WebWorks Camera access doesn't work

I believe that the alert simply doesn't fire but JS execution continues



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)