Display Simple Web Page In My Application Using Blackberry BrowserField

Posted by ankit on Stack Overflow See other posts from Stack Overflow or by ankit
Published on 2010-04-19T05:20:40Z Indexed on 2010/04/19 5:23 UTC
Read the original article Hit count: 803

Hello All,

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

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about browserfield