Displaying a simple web page in my application using the BlackBerry BrowserField

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

I am using the code below and now all I get is a blank screen. I know the app is accessing the internet (the data transfer arrow is blinking in the top right corner), but not sure why not display it.

The code I use 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 notes:

  • I am using the http-connection- factory class from www.versatilemonkey.com only because they have implemented the abstract httpConnection class. If someone can also point me to how to implement my own, that would be great.

  • I am using '0' for flags for getBrowserContent function. I looked through the rimn documentation and couldn't find an explanation for them.

Any help would be greatly appreciated.

Thanks, Ankit

+2


a source to share


1 answer


Whether you run it in a simulator or a real device. If on a real device, what media are you working on? The reason I am asking is because if you are on a GSM network (like AT&T or T-Mobile in the US), you will most likely need to configure the APN in your device settings or provide a connection URL ... Taking a look at the code of the HTTP connections library used, I don't see anything there to add APN settings to the URL, so if it's not configured in device settings than Direct TCP won't work. This leaves WAP2 and Wi-Fi - not all devices have Wi-Fi, and in my experience not all devices / media support WAP2.



+1


a source







All Articles