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
Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: Starting up camera with new API?

I did not. I added everything through the Permissions section of the config.xml control panel in Eclipse. I don't see blackberry.media.camera as an option. Should I just manually add it in through a text editor? Everytime i've done anything in the file outside of Eclipse, I get an 'out of sync' message when I then try to interact with it again in Eclipse. Does this missing blackberry.media.camera option mean I might have the wrong version of Webworks?
Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Starting up camera with new API?

MMC: The eclipse plugin you are using does not have support for the camera API. You will need to download the most recent version of the SDK which is no longer bundled into an eclipse plugin.

 

For information on why eclipse is no longer supported, read this - http://devblog.blackberry.com/2011/06/blackberry-webworks-tooling-evolved/

 

For more information about using Ripple instead of eclipse read this - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-use-Ripple-instead-of-the...



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)
Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: Starting up camera with new API?

AHA! Thanks so much! I've just started with Webworks within the few months. It's been a confusing ride since then. :smileyhappy:

Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: Starting up camera with new API?

I set up Ripple and installed the Webworks 2.1 SDK. When I open my index.html within Ripple and try to click on to my 'Take a Picture' button, I get this error:

 

Error in supported: TypeError: Cannot read property 'camera' of undefined. 

 

I've included the <feature id="blackberry.media.camera" required="true" version="1.0.0.0"/> line in my config.xml. I've included the entire config.xml contents below. I'm going to try to compile it to see if it makes a difference. I don't know if this issue is Ripple-related or if my code is wonky.

 

 <?xml version="1.0" encoding="UTF-8"?><widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0.0">  <name>CameraTest5</name>  <author>FCNY</author>  <feature id="blackberry.app" required="true" version="1.0.0.0"/>  <feature id="blackberry.app.event" required="true" version="1.0.0.0"/>  <feature id="blackberry.identity" required="true" version="1.0.0.0"/>  <feature id="blackberry.identity.phone" required="true" version="1.0.0.0"/>  <feature id="blackberry.invoke" required="true" version="1.0.0.0"/>  <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0"/>  <feature id="blackberry.invoke.CameraArguments" required="true" version="1.0.0.0"/>  <feature id="blackberry.invoke.JavaArguments" required="true" version="1.0.0.0"/>  <feature id="blackberry.io.dir" required="true" version="1.0.0.0"/>  <feature id="blackberry.io.file" required="true" version="1.0.0.0"/>  <feature id="blackberry.media.camera" required="true" version="1.0.0.0"/>  <feature id="blackberry.message" required="true" version="1.0.0.0"/>  <feature id="blackberry.system" required="true" version="1.0.0.0"/>  <feature id="blackberry.system.event" required="true" version="1.0.0.0"/>  <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0"/>  <feature id="blackberry.ui.menu" required="true" version="1.0.0.0"/>  <feature id="blackberry.utils" required="true" version="1.0.0.0"/>  <feature id="blackberry.widgetcache" required="true" version="1.0.0.0"/>  <feature id="blackberry.widgetcache.CacheInformation" required="true" version="1.0.0.0"/>  <content src="index.html"/></widget>

 

Developer
Posts: 588
Registered: ‎05-29-2009
My Device: 9100

Re: Starting up camera with new API?

I have the same situation in ripple, but then when i test it in a real device, camera is working but no success or error method is launched.
Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Starting up camera with new API?

Camera is not currently supported on Ripple but it is on their roadmap, this is why it does not work ithere.


On the device using 6.0 it should work, I have tested it myself on a Torch. The trick is that an alert dialog will not pop up for testing because the camera app is still being displayed at the same time.

 

Try something like this  

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
<script  language="javascript" type="text/JavaScript" >
function takePicture() {
    try {
      blackberry.media.camera.takePicture(successCB, closedCB, errorCB);
    } catch(e) {
      alert("Error in supported: " + e);
    }
  }

  function successCB(filePath) {   
      document.getElementById("path").innerHTML = filePath;
    
    //alert("Succeed: " + filePath);
  }

  function closedCB() {
   // alert("Camera closed event");
  }

  function errorCB(e) {
    alert("Error occured: " + e);
  }
</script>
<title>Camera Test Widget</title>
</head>
<body >
<p>Test the Camera by pressing the button below</p>
<b><a href="#" onclick="takePicture();">Take a Picture</a></b>
<div id="path"></div>
</body>
</html>


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: 588
Registered: ‎05-29-2009
My Device: 9100

Re: Starting up camera with new API?

Thanks hifetz, you were right.
Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: Starting up camera with new API?

Hi hifetz, thanks so much for the code. I got the app compiled correctly after some issues(unfinished registering of signing keys, incomplete config.xml, etc). When I click on the 'Take a Picture' link, I get the TypeError: Error in supported: TypeError: Cannot convert 'undefined' as an object.

 

I used the code you posted above as index.html. My config.xml included all available permissions. I'm using Webworks SDK 2.1. I packaged it using the 2.1 Webworks packager. Any idea what's going wrong? This camera issue is driving me crazy!

Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: Starting up camera with new API?

I think the device i'm using is still on 5.0. I'm going to upgrade to 6 and see if this code then works. I believe my users will be on 5. Is there any way to access the camera using 5 without writing custom java/javascript code? If worse comes to worst I suppose I could always have them upgrade to 6.

Regular Contributor
Posts: 50
Registered: ‎02-14-2011
My Device: Not Specified

Re: Starting up camera with new API?

Please disregard, I finally got the camera working!