Need code example on how to run an Android service forever in the background even when device sleeping, like Whatsapp?
问题 I have tried various ways to achieve this, but my service eventually gets killed. I want to use AlarmManager to trigger a class every one hour. Even if the device is sleeping, it should sent a flashing LED alert, vibration or sound. In any case, it should run forever. I have noticed that Whatsapp is always running, even though I kill all the running apps and clear the memory, put the device to sleep, and still Whatsapp receive messages and alerts me. How are they doing it? I want to do the