使用javascript blackberry app启动默认/本机浏览器

时间:2012-12-05 11:48:11

标签: javascript blackberry

<?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" rim:header="ipaidabribenaija.com Breaking News and News Updates">
<name>ipaidabribenaija.com</name>
<description>First for Breaking News and News Updates</description>
<content src="index.html" rim:allowInvokeParams="true"/>
<author href="http://www.centurymegasystem.com" rim:copyright="Copyright 2012 wwww.ipaidabribenaija.com" email="josiahaccounts@gmail.com" xml:lang="en" its:dir="rtl" >Josiah Gerald</author>
<feature id="blackberry.invoke.BrowserArguments" />
<rim:connection timeout="25000">
    <id>TCP_WIFI</id>
    <id>MDS</id>
    <id>BIS-B</id>
    <id>TCP_CELLULAR</id>
    <id>WAP2</id>
    <id>WAP</id>
    </rim:connection>
<license>Copyright (c) 2012 ipaidabribenaija.com.</license>
<icon src="images/icon.png" /></widget>

<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Breaking News and News Updates</title>
<script type="text/javascript">
    var args = new blackberry.invoke.BrowserArguments('http://www.ipaidabribenaija.com');
    blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
    /*function openWebLinkInBrowser() {
    // open web link in browser
        blackberry.invoke.invoke({target: "sys.browser",uri: "http://www.ipaidabribenaija.com"});
    }
    openWebLinkInBrowser();*/
</script>

我是这个节目中的新手。我有一项任务是为BlackBerry开发应用程序。

启动应用后,浏览器将打开一个特定的网址。

我有一个执行此操作的java代码。如何使用BlackBerry Webwork API实现相同功能。 上面的代码是我到目前为止所取得的成就。但是,该应用程序未在加载时启动浏览器。

提前感谢您的时间和想法。

<?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" rim:header="ipaidabribenaija.com Breaking News and News Updates">
<name>ipaidabribenaija.com</name>
<description>First for Breaking News and News Updates</description>
<content src="index.html" rim:allowInvokeParams="true"/>
<author href="http://www.centurymegasystem.com" rim:copyright="Copyright 2012 wwww.ipaidabribenaija.com" email="josiahaccounts@gmail.com" xml:lang="en" its:dir="rtl" >Josiah Gerald</author>
<feature id="blackberry.invoke.BrowserArguments" />
<feature id="blackberry.identity" />
<feature id="blackberry.invoke" />
<rim:connection timeout="25000">
    <id>TCP_WIFI</id>
    <id>MDS</id>
    <id>BIS-B</id>
    <id>TCP_CELLULAR</id>
    <id>WAP2</id>
    <id>WAP</id>
    </rim:connection>
<license>(c) 2012 ipaidabribenaija.com.</license>
<icon src="images/icon.png" /></widget>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Breaking News and News Updates</title>
<script type="text/javascript">
    var args = new blackberry.invoke.BrowserArguments('http://www.ipaidabribenaija.com');
    blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
    blackberry.app.exit();
</script>

以上代码工作正常,我在BB模拟器9930上进行了测试。 感谢您帮助@HelpMeToHelpYou。

1 个答案:

答案 0 :(得分:3)

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

您必须在配置文档中声明以下要素元素:根据以下图像enter image description here

更多信息,请访问

https://developer.blackberry.com/html5/apis/blackberry.invoke.browserarguments.html

示例代码: 请确保配置文件如下

<?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" rim:header="WebWorks Sample">
  <feature id="blackberry.invoke" />
  <feature id="blackberry.invoke.BrowserArguments" />
   <feature id="blackberry.identity" />
   <name>Hello World</name>
   <description>This is HelloWorld.</description>
   <content src="index.html"/>

</widget>

而index.html为

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, 
            initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, 
            user-scalable=no">
        <title>Hello World</title>
        <script type="text/javascript">
        function myFunction()
        {
              var args = new blackberry.invoke.BrowserArguments('http://www.blackberry.com');
   blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
        }

</script>
    </head>
    <body onload="myFunction()">
        <p>Hello World!</p>
    </body>
</html>

试试这个