1

我刚刚下载了 Java ME Platform SDK 3.0 并创建了我的第一个 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);
}
}
4

1 回答 1

2

您的手机 + 为您的应用程序提供了有效的 GPRS 或互联网连接?

在许多手机中,我们必须为应用程序设置不同的访问点,仔细检查一下

于 2010-11-17T19:26:13.980 回答