JavaME Midlet cannot establish HTTP Connection
I just downloaded the Java ME Platform SDK 3.0 and created my frist Midlet (from some Oracle Tutorial). Which works fine on the Emulator. When I deploy it on my Nokia N97 I can run it but as soon that I press "Connect" and allow to proceed I get a IOException: -1
Here is the code:
package hello;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloMIDlet extends MIDlet implements CommandListener {
...
private void connect() {
HttpConnection hc = null;
InputStream in = null;
String url = getAppProperty("HitMIDlet.URL");
try {
hc = (HttpConnection)Connector.open("http://www.google.ch");
in = hc.openInputStream();
by开发者_Go百科te[] raw = new byte[10];
int length = in.read(raw);
in.close();
hc.close();
// Show the response to the user.
String s = new String(raw, 0, length);
mMessageItem.setText(s);
}
catch (IOException ioe) {
mMessageItem.setText( ioe.toString());
}
mDisplay.setCurrent(mMainForm);
}
}
You have working GPRS or internet connectivity in your phone + for your application ?
In many phone we have to set access point for app differently double check it
精彩评论