1

How do I open a web browser from a Blackberry Webworks 2.0 application?

I tried:

http://www.blackberry.com/developers/docs/webworks/api/blackberry.invoke.BrowserArguments.html

but that doesn't want to work.

Thanks

1
  • 1
    Did you include the required features in your config file? <feature id="blackberry.invoke" /> <feature id="blackberry.invoke.BrowserArguments" /> <feature id="blackberry.identity" />
    – n4rzul
    Jul 27, 2011 at 6:47

2 Answers 2

5

I'll answer with one of my own working config files and a <script> section

<?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>Webworks</name>
  <author>De Wet Steynberg</author>
  <feature id="blackberry.app" required="true" version="1.0.0.0"/>
  <feature id="blackberry.identity" required="true" version="1.0.0.0"/>
  <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0.0"/>
  <feature id="blackberry.invoke" required="true" version="1.0.0.0"/>
  <access subdomains="true" uri="http://www.somedomain.com">
    <feature id="blackberry.app" required="true" version="1.0.0.0"/>
  </access>
  <content src="index.html"/>
  <rim:loadingScreen backgroundColor="#000000" foregroundImage=""/>
  <rim:navigation mode="focus"/>
</widget>

and the script tag that does the job:

<script>
    var args = new blackberry.invoke.BrowserArguments('http://www.blackberry.com');
    blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
</script>

Tried and tested. Perhaps create a small test example. If that doesn't work there might be something wrong with your emulator. If you get a message moaning about permissions and such, do the following:

1) From the homescreen press the menu button
2) At the bottom go to options (The icon with the wrench)
3) Go to Applications
4) Click the menu button and select "Edit Default Properties"
5) Set everything to "Allow", Menu, Save
6) Click Menu, Edit Default Permissions again
7) Click Menu, Apply Defaults to All, answer "Yes" to the popup prompt
8) Now navigate to the "Downloads" or " Applications" section and start your app up again.

These settings sometimes seem to get lost on the emulator between restarts. As long as your app remains open you can avoid lengthy recompiles and emulator reboots though.

Hope this helps

4

If you are building you app for BlackBerry 10, the format of the invocation interface has changed. It now leverages the built in system invocation framework (very powerful).

Here is how you would launch the browser app using the new system:

   blackberry.invoke.invoke({
      target: "sys.browser",
      uri: "http://www.blackberry.com"
   }, onSuccess, onError);

Fortunately, there is a great working sample app already published in Github: https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/invoke

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.