(紧急)httpConnection 模拟器上可以,但se W800 真机上不可以。
当打包把程序放到真机上时,出现如下错误
javax.microedition.io.connectionnotfoundexception
url是一个公网可访问的路径。
请各位高手解决一下。
============源代码如下=================
import java.io.*;
import java.util.Vector;
import org.kxml2.io.*;
import org.xmlpull.v1.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
public class Newsreader extends MIDlet implements CommandListener {
// static final String URL = "http://222.191.237.30:8100/asp/build.xml ";
static final String URL = "http://222.191.237.30:8100/asp/asptest.asp ";
// "http://www.newsforge.com/newsforge.xml ";
static final String TITLE = "NewsForge ";
Vector descriptions = new Vector();
List newsList = new List(TITLE, Choice.IMPLICIT);
TextBox textBox = new TextBox( " ", " ", 256, TextField.ANY);
Display display;
Command backCmd = new Command( "Back ", Command.BACK, 0);
Command backExit = new Command( "Exit ", Command.EXIT, 0);
class ReadThread extends Thread {
public void run() {
HttpConnection httpConnection = null;
try {
httpConnection = (HttpConnection) Connector.open(URL);
int status = httpConnection.getResponseCode();
if (status == HttpConnection.HTTP_OK) {
newsList.append( "链接成功 ", null);
descriptions.addElement( "链接成功 ");
System.out.println( "链接成功 ");
} else {
if (status == 404) {