WebWorks: Open Web Browser?

混江龙づ霸主 提交于 2019-12-08 07:44:40

问题


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:


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




回答2:


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



来源:https://stackoverflow.com/questions/6003341/webworks-open-web-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!