如何向应用程序添加清单权限? [英] How to add manifest permission to an application?
问题描述
我试图在 Android 中使用 HttpURLConnection
访问 HTTP 链接以下载文件,但我在 LogCat
中收到此警告:
I am trying to access HTTP link using HttpURLConnection
in Android to download a file, but I am 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 it's still giving the same exception.
推荐答案
假设您没有根据 LogCat
错误描述设置权限,这里是我的 AndroidManifest.xml
可以访问互联网的文件:
Assuming you do not have permissions set from your LogCat
error description, here is my contents for my AndroidManifest.xml
file that has access to the internet:
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application ...
</manifest>
除此之外,您应该可以从 Internet 下载文件.
Other than that, you should be fine to download a file from the internet.
这篇关于如何向应用程序添加清单权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!