In general, you can listen to a number of frequently occurring messages, such as power changes, switching screens, network switching, and so on, registering broadcastreceiver to receive messages and receiving a service that initiates a push message.
Now some manufacturers of ROM, once the user actively kill the process, then no longer deliver broadcast messages to the application, resulting in the application will not start, in this case, you can use C fork out a process, check whether the main process is killed, once killed, immediately call the shell command to start the service, This is a bit more rogue, but some applications, such as IM, are improving the user experience.
Some vendors, such as Huawei, have been killed in the process of killing, along with the process of fork-out. There are two ways to do this: 1. Prompts the user to add the app to the whitelist of the vendor cleanup program such as "Protected apps", "Clean back". 2. Use the push interface provided by the manufacturer.
How to ensure that messages are pushed to the Android