在Android Studio中添加Androidmanifest.xml中的Internet权限


在本教程中,我们将看到如何在Android Studio中添加Internet权限。

当我们在想要访问Internet的应用程序时,我们需要在Androidmanifest.xml中添加另外权限,否则应用程序将无法访问Internet。
因此,我们需要在Androidmanifest.xml文件中放入以下代码以访问应用程序中的Internet。

1
<uses-permission android:name="android.permission.INTERNET"

为什么我们需要另外许可访问应用程序中的Internet?

我们需要为用户安全添加此权限。
每当我们从播放商店下载应用程序时,它会要求使用应用程序将使用的权限。
让我们说你正在下载一份不得使用Internet的应用程序,如果我们不需要任何权限,则可能暗中将数据置于某些服务器上。
我们需要在Androidmanifest.xml中明确地将Internet权限放在androidmanifest.xml中,因此应用程序的用户将意识到它。

如何在Android Studio中添加Androidmanifest.xml中的Internet权限。

步骤1 :

转到APP - > SRC - > Main - > AndroidManifest.xml。

第2步:

复制以下代码:

1
<uses-permission android:name="android.permission.INTERNET"

第3步:

把它放在androidmanifest.xml中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.igiftidea.helloworldapp">
<uses-permission android:name="android.permission.INTERNET"
 
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".HelloWorldActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"
 
<category android:name="android.intent.category.LAUNCHER"
</intent-filter>
</activity>
</application>
 
</manifest>


原文链接:https://codingdict.com/