0

1) I made a J2ME app using LWUIT in which I am accessing internet to get info from my server.... 2) The app is perfectly connecting to my sever on Nokia, Android handsets 3) But when the same app is run on Blackberry ....I get NullPointer exception during httpconnection... 4) The code snippet is as follows

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
StringBuffer b = new StringBuffer();
InputStream is = null;
private HttpConnection connection;
try
{
        connection=(HttpConnection) Connector.open("http://curiousinc.in/ipl4app/LiveMatch.txt");
    is = connection.openInputStream();
}

5) Now why is this code not working on BB???.....I compiled BB jar & cod file using netbeans & BB SDK v4.6

bharath
  • 14,283
  • 16
  • 57
  • 95
Lajpat
  • 591
  • 5
  • 19

3 Answers3

2

If you use the LWUIT4IO to connect to the internet, I can assure you that it will work regardless of platform.

I encountered the same issue - mine wouldn't work in Android and Blackberry. So I followed Shai Almog's instructions on the LWUIT Blog here and changed all my internet connections to this. Solved my issues immediately!

Daydah
  • 372
  • 7
  • 20
1

See the Developer Knowledge Base article: What Is - Different ways to make an HTTP or socket connection

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Jisson
  • 3,566
  • 8
  • 38
  • 71
1

It does not work because Blackberry is special, i.e. does not entirely follow the norm. Use this HttpConnection factory.

ThomasRS
  • 8,215
  • 5
  • 33
  • 48