Affiliate links on Android Authority may earn us a commission.Learn more.

How to master Android Nougat’s new Direct Boot mode

August 22, 2025

If your smartphone runs out of battery and shuts down then it will reboot when you connect it to its charger. You can also find yourself in the same situation if your device reboots due to an internal error which caused the software to become unstable. However when a device is encrypted these reboots can have an unfortunate side effect, the device’s storage remains encrypted until the user enters their credentials. This means that apps that schedule alarms, or apps that provide important and timely notifications, can’t run.

This is a problem that Android 7.0 aims to solve, with the introduction of Direct Boot. In this article, we’re going to look at what this new Direct Boot featureis, and how to update your own Android apps so your users can reap the benefits of this new feature.

girl-sleeping-phone

What is Direct Boot?

Direct Boot is, essentially, the new name for that strange no-man’s land where the device has finished booting but isn’t fully initialized yet. With this new name, comes new functionality, and developers can now create apps that provide some limited functionality during this period.

Once a device has finished rebooting, the data stored on that device remains encrypted until the user enters their credentials, such as their password, PIN or pattern. If you don’t enter your credentials then the device and all of its data remains encrypted.

direct boot android studio

Apps cannot function normally until the device is decrypted, so at this point the device cannot perform essential tasks such as receiving incoming calls, emails or messages. It also means apps can’t deliver notifications, or act on scheduled alarms – in fact, the only thing an encrypted device can really do is burn through its remaining battery life.

And remember that in some of these reboot scenarios the device has rebooted unexpectedly, so unless you just-so-happen to glance over at your smartphone or tablet and catch it in the act, then you’ll have no idea that a reboot has even happened.

Let’s take this one step further: imagine you’re waiting on an important notification, such as an SMS message about where to meet your friends for lunch, or an email containing the details about the telephone interview that’s supposed to take place at some point this afternoon. Unbeknown to you, your phone automatically rebooted an hour ago, so you never received the SMS from your friends askingwhere are you, we’ve been waiting for ages!Even worse, you missed the email with details about the phone interview that was supposed to happen half an hour ago.

Okay, so this is a bit melodramatic, but this worst-case-scenario stuff isn’timpossible– or at least, it wasn’t impossible in the pre-Nougat world.

With Android 7.0’s new Direct Boot mode, missing out on job interviews or lunch dates should be a thing of the past. This new, restricted mode allows applications to perform limited tasks and access specific sections of data, even when the device is encrypted.

This is particularly exciting if your app performs tasks that the user can’t afford to miss out on due to an unexpected reboot, for example if you’re developing an alarm app, or an app that provides crucial services to the Android system or other applications. Direct Boot can also be useful for accessibility apps, as it allows users to access these services as soon as their device boots, without them having to unlock their device first.

Enabling Direct Boot in your app

If your app includes features that need to run in Direct Boot, then the first step is working out which components are required to deliver this functionality, as these are the components that you’ll need to make Direct Boot aware.

Open your project’s Manifest and then add the directBootAware XML attribute to each component that needs to run in this mode, whether that’s a specific Activity, a service, receiver, or something else, for example:

Once a device has finished booting but is still in its locked state, the system broadcasts a  LOCKED_BOOT_COMPLETED intent. You’ll also need to tell your Direct Boot component(s) to listen out for this crucial message:

Finally, in order to receive the LOCKED_BOOT_COMPLETED broadcast successfully, your app needs to request the RECEIVE_BOOT_COMPLETED permission:

Accessing Data in Direct Boot

At this point, the user still hasn’t entered their credentials, so for security reasons access to data is restricted. Since your app won’t be able to access Android’s credential protected file system in Direct Boot mode, Android 7.0 introduces a newdevice encrypted storagearea. This area uses Android Nougat’s file-based encryption to grant apps access to specific data – striking that tricky balance between security and convenience.

Let’s take a closer look at Nougat’s dual storage areas:

The availability of these different storage areas will impact on what your app can and can’t do, for example if you’re developing a messaging app, that app might be able to receive messages in Direct Boot mode, but if the contacts data is stored in the credential-encrypted area, then your app may not be able to reply to messages in Direct Boot.

The bottom line? Your app is going to have to use device encrypted storage for all its data needs while it’s in Direct Boot mode. To access this storage area, you’ll need to create and use a secondary Context instance, by calling Context.createDeviceProtectedStorageContext, for example:

As soon as the user unlocks their device, your app will have access to credential encrypted storage, and will be able to perform more actions as a result.

Since the user unlocking their device is such an important event, you’ll want to ensure that your app is notified when this happens. The good news is that the system already sends out an ACTION_USER_UNLOCKED message whenever the user unlocks their device, so you just need to create a BroadcastReceiver in your project, to listen out for this message.

Finally, you’re able to check whether the user has unlocked their device at any time, by calling isUserUnlocked(context).

Direct Boot Best Practices

What would a new feature be without some best practices? Here’s a few pointers on how to make the best use of Direct Boot in your own applications:

So what do you think of Direct Boot. Is it a feature that you will be adding to your app? Does you app need it? Please let me know in the comments below.

Thank you for being part of our community. Read ourComment Policybefore posting.