A free app for Android, by ArloSoft.
MacroDroid is a handy automation tool that lets you automate tasks on your Android device with ease. With over 70 different triggers, you can create a custom device trigger. From a simple device status trigger (like your device’s battery level) to one that checks for the receipt of new notifications, the device status, or a specific app, the MacroDroid app is your go-to solution for creating automated tasks.
Once you’ve created a custom trigger you can select the actions you want to perform. You can use the built-in ones (like dimming your screen or turning off the data connection) or create your own.