HttpConnection don't work on SL45 and A008? - URGENT HELP NEEDED
Hi!
Recently I have develop some app which make HttpConnections. The problem is that this app. won't work neither on SL45 and A008, and it work perfectly on Nokia9210 (when these app. runs on this device, the VM detects that a connection to the internet is needed. I'll make a connection to my ISP and the app works just fine)...
The problem solution is urgent so any suggestion is highly appreciated.
Thanks
Marco Caetano
Ok!
The app. runs on this devices, except the http connections.
Nokia 9210:
-Run the app.
-The MIDP try's to detect the connection of the device to the internet (over an www isp)
-If no connection is detected some dialog box is presented asking me what pre-defined connection I want to use.
-The device connects to my ISP through the connection
-The app. makes the http calls and the correct result is presented.
Siemens SL45:
-Run the app.
-The JAM try's to detect the connection of the device to the internet (over an wap isp)
-If no connection is detected, he dials immediatly to my default connection...
-Stays permanently on Dialing status...
One more thing, I've made an experience with SL45 (a simple app) and it seems like can't reach to my web server and consequently my url....
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.io.*;
import java.io.*;
/**
* An example MIDlet to fetch a page using an HttpConnection.
*/
public class HttpConnectionExample extends MIDlet {
private Display display;
private String url = "http://195.23.23.102/index.asp"; //"http://193.102.124.56/exp/index.asp";
public HttpConnectionExample() {
display = Display.getDisplay(this);
}
/**
* This will be invoked when we activate the MIDlet.
*/
public void startApp() {
// Use the specified URL is overriden in the descriptor
try {
downloadPage(url);
} catch(IOException e) {
// handle the exception
}
}
private void downloadPage(String url) throws IOException {
StringBuffer b = new StringBuffer();
InputStream is = null;
HttpConnection c = null;
TextBox t = null;
try {
long len = 0 ;
int ch = 0;
System.out.println("1");
c = (HttpConnection)Connector.open(url);
is = c.openInputStream();
System.out.println("2");
len =c.getLength() ;
if ( len != -1) {
// Read exactly Content-Length bytes
for (int i =0 ; i < len ; i++ )
if ((ch = is.read()) != -1)
b.append((char) ch);
} else {
// Read till the connection is closed.
while ((ch = is.read()) != -1) {
len = is.available() ;
b.append((char)ch);
}
}
System.out.println("3");
System.out.println(b.toString());
t = new TextBox("hello again....", b.toString(), 1024, 0);
} finally {
is.close();
c.close();
}
display.setCurrent(t);
}
/**
* Pause, discontinue....
*/
public void pauseApp() {
}
/**
* Destroy must cleanup everything.
*/
public void destroyApp(boolean unconditional) {
}
}
Thanks a lot
Marco Caetano