A smart Android splash screen for grabbing permissions

Posted on

Before Android 6.0, app permissions were relatively easy to handle… A user had to grant permissions during installation, or else an app could not be installed.

However, starting in Android 6.0, a user can either deny specific app permissions during installation, or revoke them after install. Although this is useful from a user’s point of view, this can also be problematic for apps that require a permission as a critical part of the app’s functionality. In this case, what the developer needs is a way of telling the user:

This app simply cannot continue until it has the permissions it needs.

One partial solution to this problem is to design a splash screen that has the following functionality:

  1. If the user is either on a pre-Android 6.0 device OR a post-Android 6.0 device where the necessary permissions have been granted, the splash screen displays itself for a few seconds, then starts the main app Activity.
  2. If the user is on a post-Android 6.0 device and the necessary permissions have not been granted, the splash screen displays itself until the user grants the required permissions.

The way we accomplish the final task is to start the splash screen with a dialog asking the user to grant the required permissions. Then:

  1. If the user grants the permissions, we wait for the splash screen timeout, and start the next activity.
  2. If the user denies the permissions, the dialog pops back up and the app does not continue past the splash screen. Furthermore, the dialog reappears every time the permissions are denied, unless the user selects the “Never ask again” option. In this case, the user will be stuck on the splash screen until they go into the Android settings and give the app the required permissions (see video above).

Before we get to the implementation, there are two things to note:

  1. If you don’t want the user to see a splash screen when the permissions are granted, then you can just set the timeout to 0.
  2. The splash screen concept will only enforce permissions during app startup. As demonstrated in the video above, if the user revokes permissions after the app has continued past the splash screen, then you must deal with that problem later in your code. The splash screen is simply a good first line of defense.

Without further ado, here is your splash screen Activity. We will dissect it after the jump:

Although you could insert this code directly into your project, changing the return value of getNextActivityClass to whatever class you want to start after the splash screen times out, I would highly recommend creating an abstract version of the SplashScreenActivity code so that can use it in multiple projects without having separate copies. Specifically, I would recommend that you change the class declaration to

abstract public class SplashPermissionsActivity extends Activity

and replace the entire getNextActivityClass function with the declaration

abstract public Class getNextActivityClass();

Then, for each new app, you would simply create a new derived Activity class, such as

public class MySplashScreenActivity extends SplashScreenActivity {
    public Class getNextActivityClass() {
        return MyMainActivity.class;


  • If you are not using the abstract form of SplashScreenActivity, then you wold include SplashScreenActivity in your AppManifest. Otherwise, you would include whichever class extends it, such as MySplashScreenActivity.
  • The entire sample app can be found on Github.
  • You can try out the app in the play store here.