我正在请求以下请求,我在android应用程序中遇到异常。
URL url = new URL(strURL);
URLConnection urlConnection = url.openConnection();
try {
HttpURLConnection httpConn = (HttpURLConnection) urlConnection;
httpConn.setRequestMethod("GET");
httpConn.connect();
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
is = httpConn.getInputStream();
}
} catch (Exception ex) {
System.out.println(ex);
}
获取以下异常
java.net.SocketException: Permission denied
最佳答案
将<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
添加到清单