如何体现的权限添加到Android应用程序?应用程序、权限、Android

2023-09-11 12:05:46 作者:够

我想在Android中使用的HttpURLConnection 来下载一个文件来访问http链接,但得到的 LogCat中:

I am trying to access http link using HttpURLConnection in Android to download a file, but getting this warning in LogCat:

WARN / System.err的(223):java.net.SocketException异常:权限被拒绝(也许缺少INTERNET权限)

WARN/System.err(223): java.net.SocketException: Permission denied (maybe missing INTERNET permission)

我已经加入android.Manifest.permission到我的应用程序,但它仍然给了同样的异常。

I have added android.Manifest.permission to my application but its still giving the same exception.

推荐答案

假如,你没有从你的 LogCat中错误描述设置权限,这是我的内容,我 AndroidMainfest.xml 文件,该文件有访问互联网:

Assuming, you do not have permissions set from your LogCat error description, here is my contents for my AndroidMainfest.xml file that has access to the internet:

<manifest xlmns:android...>
 ...
 <uses-permission android:name="android.permission.INTERNET" />
 <application ...
</manifest>

除此之外,你应该罚款从互联网上下载文件。

Other than that, you should be fine to download a file from the internet.