使用 Blackberry BrowserField 在我的应用程序中显示简单的网页

发布于 2024-08-29 01:06:35 字数 1537 浏览 6 评论 0原文

我想做的是在我的应用程序中显示一个简单的网页(没有 javascript、cookie 或任何脚本,并且不尝试检测任何事件,例如鼠标单击等)。

我正在使用下面的代码,现在我得到的只是空屏幕。我知道应用程序正在访问互联网(数据传输箭头在右上角闪烁),但不确定为什么它不渲染。

我使用的代码是:

HttpConnectionFactory factory = new HttpConnectionFactory("www.google.ca",HttpConnectionFactory.TRANSPORT_WIFI | HttpConnectionFactory.TRANSPORT_WAP2 | HttpConnectionFactory.TRANSPORT_DIRECT_TCP);

while(true)
{
     try
     {
          HttpConnection connection = factory.getNextConnection();
          try
          {
              BrowserContent bc = RenderingSession.getNewInstance().getBrowserContent(connection,null,0);
              Field f = bc.getDisplayableContent();
              add(f);  
          }
          catch(RenderingException e)
          {
              //Log the error or store it for displaying to
              //the end user if no transports succeed
              System.out.println("error with rendering page");
          }
    }
    catch(NoMoreTransportsException e)
    {
           //There are no more transports to attempt
           //Dialog.alert( "Unable to perform request" ); //Note you should never
           //attempt network activity on the event thread
           System.out.println("no more transport");
           break;
    }
}

需要注意的一些要点:

  1. 我使用 www.versatilemonkey.com 中的 http-connection-factory 类只是因为它们实现了抽象 httpConnection 类。如果有人也能指出我如何实现我自己的,那就太好了。

  2. 我使用“0”作为 getBrowserContent 函数的标志。我查看了 rimn 文档,但找不到它们的解释。

任何帮助将不胜感激。

谢谢, 安基特

What I am trying to do is display a simple web page in my application (no javascript,cookies or any scripting and not trying to detect any events such as mouse click etc.).

I am using the code below and right now all I get is empty screen .. I know that the application is accessing the internet (the data transfer arrow flashes in the top right corner) but not sure why its not rendering.

The code I am using is :

HttpConnectionFactory factory = new HttpConnectionFactory("www.google.ca",HttpConnectionFactory.TRANSPORT_WIFI | HttpConnectionFactory.TRANSPORT_WAP2 | HttpConnectionFactory.TRANSPORT_DIRECT_TCP);

while(true)
{
     try
     {
          HttpConnection connection = factory.getNextConnection();
          try
          {
              BrowserContent bc = RenderingSession.getNewInstance().getBrowserContent(connection,null,0);
              Field f = bc.getDisplayableContent();
              add(f);  
          }
          catch(RenderingException e)
          {
              //Log the error or store it for displaying to
              //the end user if no transports succeed
              System.out.println("error with rendering page");
          }
    }
    catch(NoMoreTransportsException e)
    {
           //There are no more transports to attempt
           //Dialog.alert( "Unable to perform request" ); //Note you should never
           //attempt network activity on the event thread
           System.out.println("no more transport");
           break;
    }
}

Some points to note:

  1. Im using the http-connection-factory class from www.versatilemonkey.com only becuase they have impelemented the abstract httpConnection class. If someone can also point me on how to implement my own that would be great.

  2. I am using '0' for the flags for getBrowserContent function. I looked through the rimn documentation and could not find an explanation for them.

Any help would be greatly appreciated.

Thanks,
ankit

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

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

发布评论

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

评论(1

葬シ愛 2024-09-05 01:06:35

您是在模拟器还是真实设备中运行它?如果在真实设备上,您使用哪个运营商?我问的原因是,如果您使用的是 GSM 网络(例如美国的 AT&T 或 T-Mobile),您很可能需要在设备设置中配置 APN 或在连接 URL 上指定 APN。看一下您正在使用的 HTTP 连接库的代码,我没有看到任何将 APN 设置附加到 URL 的内容 - 因此,如果未在设备设置中进行配置,则直接 TCP 将无法工作。剩下的就是 WAP2 和 Wi-Fi - 并非所有设备都有 Wi-Fi,而且根据我的经验,并非所有设备/运营商都支持 WAP2。

Are you running this in a simulator or real device. If on a real device, what carrier are you on? The reason I ask is that if you're on a GSM network (such as AT&T or T-Mobile in the US), you will most likely need to have an APN configured in your device settings or specified on the connection URL. Taking a peek at the code for the HTTP connection library you're using, I don't see anything in there to append APN settings to the URL - so if it's not configured in the device settings than Direct TCP won't work. That leaves WAP2 and Wi-Fi - not all devices have Wi-Fi and from my experience not all devices/carriers support WAP2, either.

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