Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Android Manifest
2.1.
Version Information
2.2.
Application
2.3.
Permission
2.4.
Uses Configuration
2.5.
Uses library
2.6.
Action
3.
FAQs
4.
Key Takeaways  
Last Updated: Mar 27, 2024
Easy

Android Manifest

Author Pradeep Kumar
0 upvote
gp-icon
Fundamentals of react native
Free guided path
7 chapters
15+ problems
gp-badge
Earn badges and level up

Introduction

In this blog, we will look into the Android Manifest file of Android. The manifest file describes the structure and metadata of an application, which makes it a vital aspect of any project. It also defines the components and requirements of a project. 

In this article, we will be using the Android Studio application, so in case you haven't yet set up the application on your system, you can check out this article.

Android Manifest

This file contains nodes for each of the ActivitiesServicesContent Providers, and Broadcast Receiver that make up the application, and it governs how they interact with each other and other applications using Intent Filters and Permissions. For example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.gridview_test">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.GridViewTest">
        <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>

A simple example AndroidManifest.xml is shown above, which declares one activity for the program.

Version Information

The manifest includes a root manifest tag with the project's package as the package attribute. It should also have an xmls:android attribute, which will provide numerous system attributes that will be used throughout the file. The android:versionCode is used to specify the current application version as a number that increases with each repetition of the version that has to be updated. The versionName parameter can also be used to provide a public version that will be shown to users. For example,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.gridview_test"
    android:versionCode = "1"
    android:versionName "1 Beta">
</manifest>

Some of the most commonly used manifest sub-node tags are:

Application

Only one application node can be found in a manifest. It specifies metadata for your application using attributes such as its title, icon, and theme. It serves as a container for the application's ActivityServiceContent Provider, and Broadcast Receiver nodes. To specify the name of our custom application class, we can use the android:name parameter. For example,

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.GridViewTest">
        <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>

Permission

Declares security permission for restricting access to this or other applications' specified components or functionalities. For this purpose, we can leverage the existing platform permissions or define our own permissions in the manifest.

Syntax:

<permission android:name="string"
            android:protectionLevel=["normal" | "dangerous" | ...]
            android:description="string resource"
            android:label="string resource"
            android:icon="drawable resource"
            android:permissionGroup="string" />

Uses Configuration

It specifies which hardware and software features are required by the program. An application can specify information such as it requires a physical keyboard or a certain navigation device in uses-configuration. For example,

<uses-configuration
  android:reqFiveWayNav="true"
  android:reqHardKeyboard= "true"
  android:reqKeyboardType= "qwerty"
  android:reqNavigation= "wheel"
  android:reqTouchScreen=  "finger" />

Uses library

This property specifies a shared library against which the program must be connected and instructs the system to include the library's code in the package's class loader.

Syntax:

<uses-library android:name="string"
  android:required=["true" | "false"] 
/>

Action

An Action is an interaction contained inside an intent filter that supports a certain purpose and contains a fulfillment that processes the intent. An intent-filter element must contain at least one action element. An intent-filter with no action elements will not accept any Intent objects. For example,

<action android:name="android.intent.action.MAIN" />
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

FAQs

1. How can we specify the size of screens that our app will be compatible with?
Ans: To do so, we can use the support-screen node. The node contains attributes for several screen sizes, and you can define whether or not your app is compatible with that screen size by specifying true or false as the value for that attribute.

2. When do we use uses-feature in the AndroidManifest.xml file?
Ans: It is used to specify which hardware features your application requires.

3. Can we specify the install location of our application?
Ans: Yes, you can specify the install location (i.e., internal or external) using the attribute android:installLocation in the manifest node.

Key Takeaways  

In this article, we have extensively discussed the Android Manifest file in Android and its importance in any android application. We discussed the kind of information and metadata that a manifest file contains.

We hope that this blog has helped you enhance your knowledge regarding the Android Manifest file, and if you would like to learn more, check out our article on Android UI layouts.  And to learn in-depth about android development, check out our Android Development course on the Coding Ninjas website. Do upvote our blog to help other ninjas grow. Happy Coding!

Previous article
Android Services
Next article
What is Android System WebView?
Guided path
Free
gridgp-icon
Fundamentals of react native
7 chapters
15+ Problems
gp-badge
Earn badges and level up
Live masterclass