views:

432

answers:

2

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

+1  A: 

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.

Marc Novakowski
A: 

Hi marc,

I am running this in the simulator, which is accessing the internet just fine (i can get to websites using the bb browser)

-ankit

ankit