Search code examples
androidbroadcastreceiverandroid-servicealarmmanagerandroid-alarms

Android background services and alarms


Recently encountered with a problem when Android 4.4 killed my app's Service and AlarmManager when device going into a sleep mode (START_STICKY param doesn't helps). I tried a lot of things, but nothing works as I need.

In my task manager app I always see a lot of processes of non-default apps such as Google+, Skype, Google Drive end some else that working in real time and never were killed by the system.

I want to ask more experienced developers how to create Service or Alarm that will not be killed by the system or this is impossible on some Android assemblies?


Solution

  • This is not a kind of programming answer, because the reason of not working is not inside Your code. I stumpled about that too before two weeks. My service allways stopped and I never understood why, until I detected the "Power Saving" Option inside the settings (my device Huawei Ascend Mate 7) Navigate:

    Settings --> Power Saving --> on the top Power Info --> keep running after screen off.

    Here You can enable or disable apps, that should run in the background if the screen goes to sleep.

    Also if it is not the correct answer, It´s too long for a comment, and maybe it helps others with this problem.