Add internet permission in AndroidManifest.xml in android studio

In this post, we will see how to add internet permission in android studio.

When you are working on app which wants to access internet, you need to add extra permission in androidManifest.xml else your application won't be able to access internet.
So you need to put below code in AndroidManifest.xml file to access internet in your app.
<uses-permission android:name="android.permission.INTERNET" />

Why do you need to put extra permission to access internet in your app? 

You need to add this permission for user security. Whenever you download an app from play store, it asks for permission that application will use.
Lets say you are downloading an application which must not use internet at all and if you don't require any permission for that, it might be secretly putting data on some server. You need to explicitly put internet permission in AndroidManifest.xml, so user of your app will be aware of it.

How to add internet permission in AndroidManifest.xml in android studio. 

Step 1 : 

Go to app -> src -> main -> AndroidManifest.xml.

Step 2:

Copy following code:
<uses-permission android:name="android.permission.INTERNET" />

Step 3: 

Put it in AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.java2blog.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>
Done, we have added internet permission to AndroidManifest.xml. Your application must be able to access internet now.

Written by Arpit:

If you have read the post and liked it. Please connect with me on Facebook | Twitter | Google Plus

 

Java tutorial for beginners Copyright © 2012