开发者

WebWorks: Open Web Browser?

开发者 https://www.devze.com 2023-03-05 17:36 出处:网络
How do I open a web browser from a Blackberry Webworks 2.0 application? I tried: 开发者_Go百科http://www.blackberry.com/developers/docs/webworks/api/blackberry.invoke.BrowserArguments.html

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

I tried:

开发者_Go百科

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

but that doesn't want to work.

Thanks


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消