i have the following problem. This midlet works fine when i execute it in the emulator, but when i upload it to my motorola i290 (with nextel company), and i start it, it freezes. So never starts (the program starts doing a request to a php page)
Here is the code, if anyone knows why my program work fine in the Wireless Toolkit emulator and not in the phone, please let me know. Thanks
This is my “Connection” method
String getGrade(String url) throws IOException {
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
int x = 5, y =7;
try {
c = (HttpConnection)Connector.open(url,Connector.READ,true);
c.setRequestMethod(HttpConnection.GET);
c.setRequestProperty("IF-Modified-Since", "10 Nov 2000 17:29:12 GMT");
c.setRequestProperty("User-Agent","Profile/MIDP-2.0 Confirguration/CLDC-1.1");
c.setRequestProperty("Content-Language", "en-CA");
os = c.openOutputStream();
is = c.openDataInputStream();
int ch;
while ((ch = is.read()) != -1) {
b.append((char) ch);
System.out.println((char)ch);
}
t = new TextBox("Final Grades", b.toString(), 1024, 0);
} finally {
if(is!= null) {
is.close();
}
if(os != null) {
os.close();
}
if(c != null) {
c.close();
}
}
//display.setCurrent(t);
return b.toString();
}
I had the same issue with Sony Ericsson and what i found out is that there URL is sometime truncated when its too long. Try USING POST Instead
This worked for me ….. Note Change packet to the relevant information