黑莓手机浏览问题

发布于 2024-10-16 03:19:27 字数 497 浏览 9 评论 0原文

我开发了一个应用程序,通过使用诺基亚手机的 j2me 的移动应用程序访问网络,但是当我尝试在黑莓设备上运行此应用程序时,我遇到了问题,没有网站想要打开,它只是冻结 谁能帮助我,因为我找不到任何解决方案 这些是我在应用程序中使用的代码行,

我用这行代码从网络上读取内容

hc = (HttpConnection) Connector.open(url); dis = hc.openDataInputStream(); 
int dataleft = dis.available(); 
for (int j = 0; j < dataleft; j++) {
     buffer.append((char) dis.read()); 
}
dis.close(); 
hc.close();

,并用这一行打开网站

this.platformRequest("http://stackoverflow.com/questions");

i developed an application that access the web through the mobile application using j2me for nokia cellphones but when i tried to run this application on blackberry devices i got a problem with it, no website want to be opened, it just freezes
so can anyone help me pls cos i could not find any solution for it
these r the lines of code that i'm using in the application

this line i'm using to read something from web

hc = (HttpConnection) Connector.open(url); dis = hc.openDataInputStream(); 
int dataleft = dis.available(); 
for (int j = 0; j < dataleft; j++) {
     buffer.append((char) dis.read()); 
}
dis.close(); 
hc.close();

and this line to open a website

this.platformRequest("http://stackoverflow.com/questions");

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

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

发布评论

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

评论(1

挥剑断情 2024-10-23 03:19:27

您可能正在事件线程上运行该代码(其中存在一些问题...不要依赖 available() 来保证准确,您应该只调用 read() 直到它返回 -1),这是一个很大的问题- 黑莓手机上不行。该应用程序可能会尝试提示用户授予发出 HTTP 请求的权限,但由于偶数线程被阻止,因此无法执行此操作。这里有关于 BlackBerry 事件线程上该做什么和不该做什么的很好的描述:

http://www.blackberry.com/archives/182 Thinkingblackberry.com/archives/182

HttpConnection的API文档中也提到了:

该接口执行阻塞输入和输出操作。如果此接口的实现从主事件线程内打开连接,则应用程序将锁定。通过从与主事件线程分离的线程内打开连接来防止应用程序锁定。

API 文档位于:

http://www .blackberry.com/developers/docs/4.5.0api/javax/microedition/io/HttpConnection.html

You're probably running that code (which has some issues... don't depend on available() to be accurate, you should just call read() until it returns -1) on the event thread, which is a big no-no on the BlackBerry. The app is likely trying to prompt the user for permission to make the HTTP request, but since the even thread is blocked it can't do it. There's a pretty good description of what to do and not do on the BlackBerry event thread here:

http://www.thinkingblackberry.com/archives/182

It's also mentioned in the API documentation for HttpConnection:

This interface performs blocking Input and Output operations. An application will lock if an implementation of this interface opens a connection from within the main event thread. Prevent an application from locking by opening a connection from within a thread that is separate from the main event thread.

The API docs are at:

http://www.blackberry.com/developers/docs/4.5.0api/javax/microedition/io/HttpConnection.html

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