如何使用 JavaMe 在默认浏览器中打开链接?

发布于 2025-01-08 13:03:11 字数 608 浏览 4 评论 0原文

需要跨设备 - 适用于支持 JavaME 的每个移动制造商 -

特别是:当应用程序打开时,它会重定向到移动设备默认浏览器中的(有线)链接。

找到了如何在移动 Java 应用程序中执行此操作,但尚未找到 JavaME 的示例。

我正在使用 JavaME、Sun Java Wireless Tool Kit 2.5.2 和 eclipseME。

编辑: 我正在尝试这样做:

        try {
        platformRequest("http://www.stackoverflow.com");
        destroyApp(true);
        notifyDestroyed();
    } catch (ConnectionNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

但不确定它是否适用于所有平台。另外,为什么应用程序必须被销毁?

Need to be cross-device -working for every mobile manufacturer that gives support to JavaME-

In particular: when the application is open, it redirects to a (cabled) link in the default browser of the mobile device.

Found how to do it in a not mobile Java app, but have not found example for JavaME.

I'm using JavaME, with Sun Java Wireless Tool Kit 2.5.2, and eclipseME.

EDIT:
I'm trying to do:

        try {
        platformRequest("http://www.stackoverflow.com");
        destroyApp(true);
        notifyDestroyed();
    } catch (ConnectionNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But not sure about if it will work in all platforms. Also, why the app must be destroyed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谜泪 2025-01-15 13:03:11

好了,是这样的,请看一下代码的注释:

            // In startApp()

    boolean mustExit = false;
    try {

        /**
         * mustExit - Boolean
         * 
         * Some MIDP platforms are more restricted than others.
         * For example, some don't support concurrent processing,
         * so the MIDlet must exit before the platform can honor
         * a service request.
         * 
         * If <true> destroy the app. So the browser
         * can start.
         */
        mustExit = platformRequest("http://www.stackoverflow.com");
    } catch (ConnectionNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if(mustExit){
        destroyApp(true);
        notifyDestroyed();
    }

另外,如果你是在Linux下,你必须为模拟器设置一个默认浏览器。转到 yourPath/Java/lib/system.config 并在最后添加以下行:(

# Associate the Mozilla browser with platformRequest() - Linux
com.sun.midp.midlet.platformRequestCommand: /usr/bin/firefox

当然可以是其他浏览器)

现在在模拟器中运行它。或者创建 .jad.jar 并在您的物理手机中运行它。

Well, this is how, please read the comments of the code:

            // In startApp()

    boolean mustExit = false;
    try {

        /**
         * mustExit - Boolean
         * 
         * Some MIDP platforms are more restricted than others.
         * For example, some don't support concurrent processing,
         * so the MIDlet must exit before the platform can honor
         * a service request.
         * 
         * If <true> destroy the app. So the browser
         * can start.
         */
        mustExit = platformRequest("http://www.stackoverflow.com");
    } catch (ConnectionNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    if(mustExit){
        destroyApp(true);
        notifyDestroyed();
    }

Also, if you are under Linux, you must set a default browser for the emulator. Go to yourPath/Java/lib/system.config and, at the end, add the following line:

# Associate the Mozilla browser with platformRequest() - Linux
com.sun.midp.midlet.platformRequestCommand: /usr/bin/firefox

(could be another browser of course)

Now run it in your emulator.Or create the .jad and .jar an run it in your physical phone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文