在本机 BlackBerry 应用程序中显示简单的 HTML [英] Display simple HTML in a native BlackBerry application

查看:31
本文介绍了在本机 BlackBerry 应用程序中显示简单的 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在我的本机 BlackBerry 应用程序中显示一些简单的 HTML 块,而不是从 URL 返回.这类似于现有的 Stackoverflow 问题(例如 此处此处),但我需要帮助才能运行实际的 BlackBerry 示例代码(或者可能是某人告诉我为什么这注定是行不通的!).

BlackBerry 网站有一些基于不同 API 版本的示例浏览器"代码:
V4.5 API 示例
V5.0 API 示例

我找到了组件包附带的示例代码(更多信息 here),并尝试使 V4.5 示例代码工作.我希望这是一个有用的起点...

我已经设法让 BrowserFieldDemo 在 Eclipse 中编译并在模拟器中运行(我需要注释掉整个 BrowserContentManagerDemo.java 否则该类将运行).

不幸的是,我在模拟器中只看到白屏.当我添加日志记录并使用调试器时,这里的 getBrowserContent() 行似乎都出错了:

BrowserContent browserContent = null;尝试{browserContent = _renderingSession.getBrowserContent(connection, this, e);<剪断>}捕获(重新渲染异常){EventLogger.logEvent(ID, (re + "").getBytes(), EventLogger.ERROR);System.err.println(re);}

返回的异常是:

<块引用>

net.rim.device.api.browser.field.RenderingException:连接中的 IOException

我已经尝试使用 4.5.0 和 4.7.0 组件包构建和使用模拟器,但它们都有相同的症状.

如果我将 samples.cod 文件推送到我的设备并启动它,我会收到启动示例时出错:模块‘示例’尝试访问安全 API".大概我需要用我的代码签名密钥(我有)来签署示例代码,我不知道如何在 Eclipse 中这样做.

所以,我的问题是:

1) 真的有人让这个 V4.5 示例代码工作吗?我应该放弃模拟器并使用该设备吗?

2) 这种 V4.5 方法可以用于显示我拥有的一些简单的 HTML 数据吗?例如我可以使用本地主机 URL,还是创建自定义 HttpConnection 来提供数据?

如果可能,我需要支持运行 V4.5、V4.7 和 V5.0 的 BlackBerry 型号.

任何提示将不胜感激!

解决方案

确保在启动设备模拟器之前启动 MDS 模拟器.使用 HTTP 的所有或大部分示例都没有指定传输,因此将使用默认的 MDS 传输,这意味着如果您没有运行 MDS 模拟器,那么它将无法建立 HTTP 连接.

I want to be able to display some simple chunks of HTML in my native BlackBerry app, NOT returned from a URL. This is similar to existing Stackoverflow questions (e.g. here and here), but I need help getting the actual BlackBerry sample code to run (or perhaps somebody to tell me why this is doomed to not work!).

The BlackBerry website has some sample 'browser' code based on different API versions available:
V4.5 API sample
V5.0 API sample

I've found the sample code that ships with the Component Packs (more info here), and tried to get the V4.5 sample code to work. I was hoping this would be a useful starting point...

I've managed to get BrowserFieldDemo to compile in Eclipse and run in the Simulator (I needed to comment out the whole of BrowserContentManagerDemo.java otherwise that class would run instead).

Unfortunately, I just get a white screen in the Simulator. When I add in logging and use the debugger, it all seems to go wrong at the getBrowserContent() line here:

BrowserContent browserContent = null;

try
{
    browserContent = _renderingSession.getBrowserContent(connection, this, e);
    <snip>
}
catch (RenderingException re)
{
  EventLogger.logEvent(ID, (re + "").getBytes(), EventLogger.ERROR);
  System.err.println(re);
}

The Exception returned is:

net.rim.device.api.browser.field.RenderingException: IOException in connection

I've tried building and using the Simulator with the 4.5.0 and 4.7.0 Component Packs, but they both have the same symptoms.

If I push the samples.cod file to my device and start it, I get "Error starting samples: Module 'samples' attempts to access a secure API". Presumably I would need to sign the sample code with my code signing keys (which I do have), which I am not sure how to do in Eclipse.

So, my questions are:

1) Has anybody actually got this V4.5 sample code working? Should I give up on the Simulator and use the device instead?

2) Can this V4.5 approach work for displaying some simple HTML data that I have? e.g. can I use a localhost URL, or perhaps create a custom HttpConnection to serve up the data?

I need to support BlackBerry models running V4.5, V4.7 and V5.0, if at all possible.

Any tips would be appreciated!

解决方案

Make sure that you launch the MDS simulator before launching the device simulator. All or most of the samples that use HTTP don't specify a transport and so will use the default MDS transport, which means if you don't have MDS simulator running then it won't be able to make an HTTP connection.

这篇关于在本机 BlackBerry 应用程序中显示简单的 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆