Close
Topic : AndroidManifest.xml File: Working with Manifest: | Add Permissions:

AndroidManifest.xml:

The AndroidManifest.xml is a powerful file in the Android platform that allows us to describe the functionality and requirement of our application to Android. this file contains information of our package, including components of the application such as Activities, services, broadcast receivers, content providers etc.

Working With AndroidManifest.xml file is not easy. it's difficult to work with it. But Xamarin.Android Helps to minimize this difficulty by allowing us to add custom attributes to our classes, which will then be used to automatically Generate the Manifest for us.



Using Xamarin, 99% Programmers Never Need to manually modify AndroidManifest.xml file.


  • Manifest Responsibilities:

    » It declares the Minimum API Level Required by the Application.
    » It declares the Permissions required by the application, e.g. Camera, location, etc.
    » It gives permission to hardware and software features used or required by the applications.
    » It lists the Libraries that the Application must be linked.



Working with Manifest file:

We can work with Manifest file using two ways, the first one is using an .XML file. the second one is using Android Manifest file. In my case, second method is easy to use. to let's discuss, how we can work with Manifest file.


AndroidManifest.xml-step-1: infobrother
  • Steps to Open Android Manifest:

    1 » Open your Project and right-click on the Project and select Properties.
    2 » Select Android Manifest.xml:



In that Window, there are some Important settings that we need to build our application. what even we did here, it will generate an XML code and will store in AndroidManifest.xml file. let's discuss these important settings to Know why we need it. and how to provide the information in this file.



Application Name:

This is the title of Our app which displays along with an icon. this is not the same name that is selected on Google Play.



Pakage Name:

This is the Unique name to identify Our App. it must begin with Lower Case Letter and with one character within it. We can use Reverse domain style with our Company name at the beginning. For Example - We can use com.infobrother.HelloWorld.



Application icon:

This is the Application icon displayed on Android Mobile Screen. It could be Company logo. We will learn how to set icon in our Drawable Resources tutorial.



Version Number:

This represents the Version of Our Application, and it should be one digit. Increasing the version indicates the newer version on Google play. We can mention Version Number like 1 or 2 or 3 and so on.



Version Name:

This is user friendly version string of the Android Application.



Install Location:

Here we can Select a Different Location to install Our Android Application. It Could be Internal Storage or External storage.



Minimum Android Version:

This is Minimum version of the Android that Our Application requires.



Target Android Version:

This is the Version of Android SDK Against which our Application compiles. By selecting the higher version, we will get the Access to new API's.



We can Edit the above all Information in Android Manifest Window, as shown in above screen shot. or we can edit in AndroidManifest.xml file. In .xml file we can edit above all information using this code.



AndroidManifest.xml-step-2: infobrother
  • Steps to Open AndroidManifest.xml file:

    » Open your Project and in Solution Explorer open Properties > AndroidManifest.xml.



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
                         package="HelloWorld.HelloWorld"  <!--Package Name-->      
                         android:versionName="1.1" <!--Version Name-->                        
                         android:installLocation="internalOnly"  <!--Install Location-->  
                         android:versionCode="1"> <!--Version Number-->      


     <uses-sdk android:minSdkVersion="23" />  <!--Minimum Android Version -->         
               android:targetSdkVersion="23" /> <!--Target Android Version-->

         <!--Application Name-->
    <application android:label="@string/app_name"></application>
</manifest>


Required Permission:

A Permission is a Restriction that limits access to a part of the code or to data on the device. The limitation is imposed to protect critical data and code that could be misused to distort or damage the user experience. In this section, we can select the Permission which required for Our Application. These Permissions Displayed on Google Play before the Application Installed.


AndroidManifest.xml-step-3: infobrother

Each Permission is identified by the Unique label. Often the label indicates the action that's restricted. Here are some Permissions that are defined by Android.



<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_TIME_ZONE" />
<uses-permission android:name="android.permission.SET_TIME" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />


We should Only request permission that Our Application requires to run. User will be prompted to allow these permissions when they download our Application from the Google play store.



We don't need to write the above code in AndroidManifest.xml file to Enable these permissions. we can Use Android Manifest to enable these permissions. just check the required permission and it will automatically edit in Our Manifest file.

















I Tried my Best to Provide you complete Information regarding this topic in very easy and conceptual way. but still if you have any Problem to understand this topic, or do you have any Questions, Feel Free to Ask Question. i'll do my best to Provide you what you need.

Sardar Omar.
InfoBrother





WRITE FOR INFOBROTHER

Advertising






Advertisement