从服务器android读取文件时拒绝权限

时间:2014-01-09 01:56:36

标签: java android

我正在尝试检查服务器上是否存在文件但是我回来的唯一文件是 打开跟踪文件时出错。许可被拒绝(13) 代码如下

 public static boolean exists(String URLName){
        try {
          Log.i("TAG", "tag "+URLName);
            HttpURLConnection.setFollowRedirects(false);
          // note : you may also need
          //        HttpURLConnection.setInstanceFollowRedirects(false)
          HttpURLConnection con =
             (HttpURLConnection) new URL(URLName).openConnection();
          con.setRequestMethod("HEAD");
          Log.i("TAG", "return code "+ con.getResponseCode());
          return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
        }
        catch (Exception e) {
           e.printStackTrace();
           return false;
        }
      }  

同样在清单上我已经包含了代码

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 

有人可以帮助我如何解决它吗?

0 个答案:

没有答案