Android Permission

Whenever we install any new application on our android phone, it asks for permssion to use certain resources like

  • camera
  • wifi
  • Network connectivity

If we allow tha app to access these resources, then only the app is installed. The permission must be explicitly defined in the Androidmanifest.xml file. All the permissions are defined in the permission tag in the main xml file.

The main permission category is uses permission. So before testing the application which requires any resource to be used, we must explicitly define that permission in our androidmanifest.xml file. Android permission, make sure that the application will work properly.

Let us take an example :

Suppose we want to check if wifi is working on the mobile or not. Then in that case we will write the code , to check if WIFI is working .

In order to check we use the

ConnectivityManager conmgr=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

boolean wifi=conmgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting());

Now if we execute this code, it is going to give you error. Because in this case we are going to access the resources

of the mobile , so we have to mention in the Androidmanifest.xml file in the uses permission

 

Now once the ACCESS_NEWTWORK_STATE android permission is added in the androidmanifest.xml file, it will execute properly.

 

android-intent