我刚刚下载了Java ME Platform SDK 3.0并创建了我的frist Midlet(来自一些Oracle教程)。哪个在模拟器上工作正常。当我在诺基亚N97上部署它时,我可以运行它,但是一旦我按下“连接”并允许继续我得到IOException:-1
以下是代码:
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();
byte[] 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);
}
}
答案 0 :(得分:2)
您的手机+为您的应用程序提供GPRS或互联网连接吗?
在许多手机中,我们必须为app设置接入点,不同地仔细检查