【android】 conn.getResponseCode(); 返回-1,没报权限错,原因可能是:

 

URL url = new URL(urlString);

   conn = (HttpURLConnection) url.openConnection();
   conn.setConnectTimeout(30 * 1000);
   conn.setReadTimeout(30 * 1000);
            conn.setRequestProperty("Range", "bytes=" + downFileSize + "-");
     
           
   
   status = conn.getResponseCode();
   if (status == HttpURLConnection.HTTP_OK
     || status == HttpURLConnection.HTTP_PARTIAL) {

 

 

 

没加<uses-permission android:name="android.permission.INTERNET"/>权限

 

你可能感兴趣的:(android,url)