Android App Permission Best Practices


Android App Permission Best Practices

All the applications available either at Google Play Store or Apple App Store requires permissions for continuity. Through requesting permissions you can protect all the sensitive information that is available from a device and should be accessible only when necessary. We are going to discuss some crucial ways to achieve better functionality of the applications without requesting unnecessary permissions.


Code of Belief for Working with Android Permissions


We commend to follow these crucial tenets when you are working with Android app permissions.

Point # 1: Only Necessary Permissions

It is exclusively dependent on how you are managing the permissions, there ought to be other ways to do the work from what you require such as the system intents, accessing identifiers and checking to the background for phone calls, without being dependent on the access to super sensitive information.

Point # 2: Pay Attention to the Permissions Required By Libraries

When you are including a library, you also need to inherit its permission necessities. You ought to be completely aware of what you’re including as well as the permissions that is intended to be required and how those permissions are going to be used.


Point # 3: Be Transparent

For a properly informed decision made by the users, make the permissions clear and state the reason for accessing them. Make the information easily accessible beside the permission requests that includes the installation, the runtime and update permissions.


Point # 4: Make System Accesses Explicit


By providing the continuous indications when you are accessing the sensitive capabilities such as camera and microphone, makes it certain to the users when you are collecting the data while smoothly avoiding the perception that you are collecting some data surreptitiously.

Permissions in Android 6.0+

The Android 6.0 Marshmallow introduced an exclusive permissions model that enables the apps to request the permissions from the users at runtime, rather indulging in permission before installation. Through the influx of Android 6.0+ mobile app development agency or developers can alter relevant changes so that the sensitive user data can be handles with extra care.

Increase in Situational Context

The users are provoked at the runtime in the context of your developed application, where for permission to access the core functionalities covered by those groups. It is evident that the users are way more sensitive and impatient to the context in which asked for the permission, and if they find a mismatch amid what you are requesting and what the purpose of your application is, it is than even more important than before to provide complete detail and explanation to the users. Explain why you are requesting for such permission and provide a follow-up dialog if the user denies the request to access permission.

Greater Flexibility in Granting Permissions

It is a good idea to monitor and observe that how many users are actually denying from giving the permissions through using Google Analytics. Through this, you can get an idea to either refactor your application to avoid from asking that permission or provide a better simple explanation for why you are in need so such permission. It is also necessary to handle the exceptional areas such as when the user denies the permission request or toggle off permission by going to the settings.

Avoid Requesting Unnecessary Permissions

For every time you would ask for permission from the user, you are actually forcing the user to make a decision. If the user is running on Android 6.0+ then they would receive permission requests during runtime, which might disturb their working. Similarly, if the user has lower than Android 6.0 than before the installation, they would be facing the permission panel. So if you are bombarding the users with permissions, then there are evident chances either they will uninstall it (above Android 6.0) or won’t install at all (below Android 6.0). Be sure to ask for a few permissions and minimize those permissions that are not much necessary.

Use an Intent

In the majority of the cases, you can select among two ways for your application to perform a particular task. Either your app asks for permission to perform the specific task itself or it can even use an intent to have other applications perform the task for them.

For instance, assume your application should almost certainly take pictures with the gadget camera. Your application can ask for the CAMERA consent, which permits your application to get to the camera straightforwardly. Your application would then utilize the camera APIs to control the camera and snap a photo. This methodology gives your application full power over the photography procedure and gives you a chance to consolidate the camera UI into your application.

In any case, if your necessity for access to client information is rare — at the end of the day, it’s not unsatisfactorily troublesome for the client to be given a runtime discourse each time you have to get to information — you can utilize a plan based demand. Android gives some framework aims that applications can use without requiring consents on the grounds that the client picks what, on the off chance that anything, to impart to the application at the time the expectation based demand is issued.

For example, an intent action type of MediaStore.ACTION_IMAGE_CAPTURE or MediaStore.ACTION_VIDEO_CAPTURE can be easily used for the capturing of the images or videos without notifying the camera object or without permission. In such a scenario, the system intent will be asking for the user’s permission on your behalf every moment an image is being captured.

If You Use Permissions

Your application has full authority over the client experience when you play out the activity. In any case, such wide control adds to the unpredictability of your code, since you have to plan a suitable UI.

The client is provoked to give consent once, either at run time or at introducing time (contingent upon the client’s Android form). From that point forward, your application can play out the activity without requiring an extra connection from the client. Be that as it may, if the client doesn’t give the consent (or repudiates it later on), your application loses the capacity to play out the task by any means.

If You Use an Intent

You don’t need to structure the UI for the activity. The application that handles the goal gives the UI.


The client can utilize their favored application for the undertaking. For instance, the client can choose their most loved photograph application to snap a photo.

In the event that the client does not have a default application for the activity, the framework prompts the client to pick an application. In the event that the client does not assign a default handler, they may need to experience an additional discourse each time they play out the activity.

Don’t Overwhelm the User

On the off chance that the client is running Android 6.0 (API level 23) or later, the client needs to allow your application its authorizations while they are running the application. On the off chance that you go up against the client with a ton of solicitations for authorizations on the double, you may overpower the client and cause them to stop your application. Rather, you ought to request authorizations as you need them.

Now and again, at least one consents may be significant to your application. It may bode well to request those authorizations when the application dispatches. For instance, in the event that you make a photography application, the application would require access to the gadget camera. At the point when the client dispatches the application out of the blue, they won’t be astonished to be requested consent to utilize the camera. In any case, if the equivalent application likewise had an element to share photographs with the client’s gets in touch with, you presumably ought not to request the READ_CONTACTS authorization at first dispatch. Rather, hold up until the client endeavors to utilize the “sharing” highlight and request the consent at that point.

On the off chance that your application gives an instructional exercise, it might bode well to ask for the application’s basic authorizations toward the finish of the instructional exercise arrangement.

Pause Media after Losing Audio Focus

For this situation, your application needs to go out of the spotlight when the client gets a telephone call and refocus just once the call stops.

The normal methodology in these cases – for instance, a media player quieting or stopping amid a telephone call – is to tune in for changes in the call state utilizing PhoneStateListener or tuning in for the communicate of android.intent.action.PHONE_STATE. The issue with this arrangement is that it requires the READ_PHONE_STATE authorization, which powers the client to concede access to a wide cross segment of touchy information, for example, their gadget and SIM equipment IDs and the telephone number of the approaching call.


You can identify whether a client is in a telephone call without the READ_PHONE_STATE or the MODIFY_PHONE_STATE consents by asking for AudioFocus for your application, which doesn’t require unequivocal authorizations (since it doesn’t get too touchy data). Essentially put the code required to find your sound in the onAudioFocusChange() occasion handler and it will run consequently when the OS moves its sound core interest. Increasingly point by point documentation on the most proficient method to do this can be found here.

Determine the Device Your Instance Is Running On

For this situation, you need an interesting identifier to figure out which gadget the occasion of your application is running on.

Applications may have gadget explicit inclinations or message (e.g., sparing a gadget explicit playlist for a client in the cloud with the goal that they can have an alternate playlist for their vehicle and at home). A typical arrangement is to use gadget identifiers, for example, Device IMEI, yet this requires the Device ID and call data consent gathering (PHONE in M+). It likewise utilizes an identifier which can’t be reset and is shared over all applications.


There are two major alternatives that can be used for the identifiers:


  • Utilize the InstanceID API. getInstance(Context context).getID() will restore a remarkable device identifier for your application occurrence. The outcome is an application example perused identifier that can be utilized as a key while putting away data about the application and is reset if the client re-introduces the application.
  • Make your own identifier that is checked to your application’s stockpiling utilizing fundamental framework capacities like randomUUID().


Create a Unique Identifier for Advertising or User Analytics

For this situation, you need a one of a kind identifier for building a profile for clients who are not marked into your application (e.g., for advertisements focusing on or estimating transformations).

Building a profile for promoting and client examination some of the time requires an identifier that is shared crosswise over different applications. Regular answers for this include utilizing gadget identifiers, for example, Device IMEI, which requires the Device ID and call data authorization gathering (PHONE in API level 23+) and can’t be reset by the client. In any of these cases, notwithstanding utilizing a non-resettable identifier and asking for a consent that may appear to be surprising to clients, you will likewise be disregarding the Play Developer Program Policies.

Lamentably, in these cases utilizing the InstanceID API or framework capacities to make an application perused ID are not suitable arrangements on the grounds that the ID may be shared crosswise over applications. An elective arrangement is to utilize the Advertising Identifier accessible from the AdvertisingIdClient.Info class by means of the getId() technique. You can make an AdvertisingIdClient.Info object utilizing the getAdvertisingIdInfo(Context) technique and call the getId() strategy to utilize the identifier. Note that this strategy is blocking, so you ought not to call it from the primary string; a nitty-gritty clarification of this technique is accessible here.


Read Here: Avoid Disaster by Following These 5 App Development Tips

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × four =