android - 从android到GAE的未知主机异常

标签 android google-app-engine

我正在尝试从 android 发布到 GAE,我遇到了未知的主机异常。这是我的代码,

HttpClient httpclient = new DefaultHttpClient();  
    HttpPost httppost = new HttpPost("http://silver-kites.appspot.com");  

    try {  
        // Add your data 
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);  
        nameValuePairs.add(new BasicNameValuePair("abc", "123"));  
        nameValuePairs.add(new BasicNameValuePair("xyz", "456"));  
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));  

        // Execute HTTP Post Request  
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        if(entity != null){
          InputStream inputStream = entity.getContent();
          ResponseText.setText(convertStreamToString(inputStream));
        }
    } catch (ClientProtocolException e) {
        ResponseText.setText(e.getMessage()); 
    } catch (IOException e) {
        ResponseText.setText(e.getMessage());
    }

当我尝试连接到 localhost:8888 时,连接被拒绝。我不知道如何通过这个。帮助我。

最佳答案

我也试过了,在 android 中仍然出现未知主机异常。是否需要做任何设置才能访问 HTTP?或者在模拟器中 http 将无法工作?

我设置了 <uses-permission android:name="android.permission.INTERNET"></uses-permission>在 android list xml 中。仍然没有希望。

有帮助吗?我 checkin 了 GAE,但我的请求没有到达那里。

这是我的代码,

HttpClient httpclient = new DefaultHttpClient();  
    HttpPost httppost = new HttpPost("http://silver-kites.appspot.com/silverscores");  

    try {  

        nameValuePairs.add(new BasicNameValuePair("name", "JP"));
        nameValuePairs.add(new BasicNameValuePair("seconds", "123"));

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));  

        // Execute HTTP Post Request  
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        if(entity != null){
          InputStream inputStream = entity.getContent();
          ResponseText.setText(convertStreamToString(inputStream));
        }
    } catch (ClientProtocolException e) {
        ResponseText.setText(e.getMessage()); 
    } catch (IOException e) {
        ResponseText.setText(e.getMessage());
    }

关于android - 从android到GAE的未知主机异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3544557/

相关文章:

android Gcm registrationID 与 Parse 等第 3 方库冲突

android - 通过 Android 3g 连接到服务器并从 phpmyadmin 检索数据

android - 如何在使用 setTextIsSelectable 禁用键盘后启用触摸键盘

python - GAE Python webapp2图片上传错误

google-app-engine - 为什么 Google Appengine 中没有唯一约束?

google-app-engine - Google App Engine 上的 Grails - 生产问题 : Response 500 Error

java - Bouncy CaSTLe 密码学 API 可以在 Android 中使用吗?

google-app-engine - 动态 html 的 GO 模板

java - 应用程序默认凭据无法创建 Google App Engine 服务帐户凭据

android - 向游标适配器android添加额外的元素