Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java me (HttpConnection)连接器。开路;http://www.google.com"); 没有响应_Java Me - Fatal编程技术网

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