How to Hide the Persistent Notification for Background Apps in Android O
Android O is looking to bring major enhancements to the Android OS we all know and love. Picture-in-picture mode for phones, notification channels, smart text selection, autofill services, and under the hood many, many changes to enhance your battery life, performance, and security. One feature that is supposed to help users sort out issues with battery life and performance is background process limitations. Without going into too much detail, apps in Android O can no longer be woken from their manifest-registered implicit broadcast receivers and they can no longer start background services without going through JobScheduler. If an app wants to start a background service, it must explicitly tell the user that it is doing so by posting a notification. However, when an app is running in the background, Android O now seemingly tacks on another persistent notification telling you what apps are running. This also occurs when an app with the SYSTEM_ALERT_WINDOW permission (such as the popular Twilight app) is currently displaying an overlay.
Although these notifications are minimized by default, they cannot be dismissed by the user or permanently blocked in Settings. This behavior is very annoying to many users, and I seriously hope that Google gives us a way to disable this notification in the final Android O/Android 8.0 release. However, if they do not, there is still a way to permanently hide the persistent background apps notification. I will showcase how to do so in a step-by-step guide, followed by an explanation of how it works as well as important caveats.
Hide the Persistent Notification in Android O
- Install the USB drivers for your particular phone if you’re on Windows (they can be found here).
- Download the ADB binary for your particular operating system (Windows, Mac, Linux). These links will always point to the latest version of the binary, so you don’t have to scour the net looking for the latest one.
- Extract the contents of the ZIP file you downloaded into an easily accessible folder on your PC (such as in the Downloads folder).
- Go to the Settings app on your phone and tap on the “About Phone” option.
- Find the Build Number and tap on it 7 times to enable Developer Mode. You’ll see a popup once it’s enabled.
- Go back to the Settings main menu and enter Developer Options so you can enable USB Debugging Mode.
- Plug your phone in to the PC and swipe down your notification panel to change the USB mode from “charge only” to “file transfer (MTP)” mode. This may not be necessary for your phone.
- On your PC, browse to the directory where you extracted the ADB binary.
- Launch a Command Prompt/Terminal in this ADB directory. For Windows users, this can be done by a Shift+Right-click then selecting the “open command prompt here” option.
- Once you’re in the Command Prompt or Terminal environment, enter the following command:
- This will start the ADB daemon. If this is your first time running ADB, you will also see a prompt on your phone asking you to authorize a connection.
- Now re-run the adb devices command from step 10, and the command prompt/terminal will print the serial number of your device. If it does, then you’re ready to move on. If not, then the USB drivers are likely not installed properly.
- Go back to the Command Prompt and enter the following command:
- Now execute the following command:
cmd appops set android POST_NOTIFICATION ignore
- You won’t get a success message or anything, but as long as you don’t see an error it should have worked. Now just reboot your phone!
Yes, I realize these are pictures of a phone screen rather than screenshots. I don’t have an Android O compatible device myself, so I asked TK to send me images.
- If you want to revert this command, enter this into the command prompt:
cmd appops set android POST_NOTIFICATION allow
How it works
Using the hidden command line interface for App Ops, Android’s user-facing permission management system, we are able to restrict the POST_NOTIFICATION permission from the “android” package. (Note: we are setting it to “ignore” rather than “deny” because “deny” could cause some errors.) I found this permission by looking at the relevant source code for AppOpsManager, which lists all of the possible permissions that can be granted/revoked, many of which are not accessible in the Android settings. The “android” package actually refers to “Android System” AKA framework-res.apk, which is responsible for the persistent notification that we are trying to get rid of.
By essentially revoking the Android System’s POST_NOTIFICATION permission, it can no longer show a notification! Sounds pretty simple, right? Unfortunately, there is a caveat to be aware of. “Android System” is responsible for more than just this notification, so any other notifications that it may post will no longer be shown. This can include the USB mode notification (which can still be changed through the setting in Developer Options) as well as some other things.
While this is a pretty drastic measure to take on our part, it’s currently the only way to hide this notification apart from rooting your phone and modifying the framework itself which is obviously something not many users are willing or able to do. I sincerely hope that Google offers a way to hide this notification in a future release of Android O, or even better remove this notification entirely. Google understandably wants to improve the user experience by notifying users when an app is running in the background that the user may not be aware of, but the method they chose is annoying for those of us who know what about each app we are using.