Open In App

How to Add Manifest Permission to an Android Application?

Improve
Improve
Like Article
Like
Save
Share
Report

An AndroidManifest.xml file must be present in the root directory of every app project’s source set. The manifest file provides crucial information about your app to Google Play, the Android operating system, and the Android build tools. Adding permissions to the file is equally important. In this article, we’ll be adding internet permissions to the AndroidManifest File.

Step by Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in Android Project just refer to this article on How to Create New Project in Android Studio. The code can be implemented in both Java and Kotlin Programming Language for Android.

Make sure you have selected Android view in Directory Structure and Click on Manifest Folder.

In the Root Directory

 

Step 2: Open the AndroidManifest.xml File.

We can add multiple attributes and various components to make our Application robust. For a detailed overview refer to the article on Application Manifest File Android.

Selecting the Manifest File

 

We now declare permission that uses the following tag

<uses-permission android:name="" />

Inside android:name=””, we need to add permission which we require.

Example for declaring internet permission

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

Now, at last, we declare the permission before the application tag in the manifest file.

XML




<?xml version="1.0" encoding="utf-8"?>
    xmlns:tools="http://schemas.android.com/tools"
    package="com.gfg.geeksforgeeks">
    
    <!-- Intern Permission -->
    <uses-permission android:name="android.permission.INTERNET" />
  
    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.GeeksForGeeks"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
  
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


Since there is no change in the Java/Kotlin MainActivity File, we’ve only provided the XML File Code.



Last Updated : 17 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads