httpUrlConnection .connect()错误崩溃

时间:2016-03-26 13:58:03

标签: android httpurlconnection facebook-android-sdk

在我的应用程序代码中

@Override
    protected String doInBackground(Void... params) {
        StringBuilder response = null;
        try {
            String request = ApplicationConstants.REQUEST_ABOUT_BASE_URI;
            URL url = new URL(request);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setReadTimeout(10000); // millis
            conn.setConnectTimeout(15000); // millis
            conn.connect();
            Log.d(TAG, "doInBackground: " + conn.getResponseCode() + " : " + conn.getResponseMessage());
            InputStream is = conn.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(is));
            String line;
            response = new StringBuilder();
            while((line = rd.readLine()) != null) {
                response.append(line);
            }
            rd.close();
            Log.d(TAG, "doInBackground: " + response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response.toString();
    }

崩溃错误

http://pastebin.com/G6bXDfJJ

无法解析主机“tools.mysite.com” 但在我的应用程序常量REQUEST_ABOUT_BASE_URI中写tools.mysyte.com/mobile.php?about

只有真正的设备,只有Android 4. +。在Android 5.0 .connect()上没问题。

为什么?

0 个答案:

没有答案