Java me (HttpConnection)连接器。开路;http://www.google.com"); 没有响应
没有回应。如何解决此问题?Java me (HttpConnection)连接器。开路;http://www.google.com"); 没有响应,java-me,Java Me,没有回应。如何解决此问题?请尝试以下方法 (HttpConnection) Connector.open("http://www.google.com"); 在许多手机和一些模拟器中,您只能在另一个线程中打开连接。也就是说,如果您尝试在主therad=UI线程中连接,它将不起作用,也不会告诉您任何事情。试着简单地将你的方法包装在一个新线程中应用程序是否正在挂起(等待)那一行?要等多久?它是否超时并引发异常?你是在设备上测试还是在模拟器上测试?您确定设备/模拟器具有良好的网络连接吗? (Http
请尝试以下方法
(HttpConnection) Connector.open("http://www.google.com");
在许多手机和一些模拟器中,您只能在另一个线程中打开连接。也就是说,如果您尝试在主therad=UI线程中连接,它将不起作用,也不会告诉您任何事情。试着简单地将你的方法包装在一个新线程中应用程序是否正在挂起(等待)那一行?要等多久?它是否超时并引发异常?你是在设备上测试还是在模拟器上测试?您确定设备/模拟器具有良好的网络连接吗?
(HttpConnection) Connector.open("http://www.google.com");
HttpConnection c = null;
InputStream is = null;
StringBuffer sb = new StringBuffer();
String request = serverUrl; // + "?loc=" + location.getLat() + "," + location.getLng() + "data=" + message.getString();
try {
c = (HttpConnection) Connector.open("http://www.google.com");
c.setRequestMethod(HttpConnection.GET); //default
int status_code=c.getResponseCode();
if(status_code!=HttpConnection.HTTP_OK)
{
//Show the failure message to user
return;
}
//Remaining part is same as your code