I have a foreground service started by startForeground() and onStartCommand reurns START_STICKY. I want to run it all the day, but it gets stopped when I play games or manually increase RAM usage by a “Fill RAM Memory” app from Google Play. (Even if it is killed, the notification is still showing.) How can I fix it?
EDIT: Or is there a better way? The service runs 3 threads which contain an infinite loop with some internet calls and then 20 min or 10 min (depends on situation) sleep. Maybe an AlarmManager or something like that.
EDIT 2: My tablet has Android 4.4 (API 19), so I can't use JobScheduler. I think I'll use AlarmManager and It'll be ok. (I found AlarmManagerExample here: https://github.com/rakeshcusat/Code4Reference)