Android app with push notifications and background process in some cases

We have an Android app that receives Push notifications via FCM and background service that works even when the app is inactive. We are facing some issues with the Android operating system that kills the background service and in other cases automatically closes notifications for our application. (Automatically turning off notifications for our app).

Our first suspect was Doze mode, introduced in Android 6 and later, but we use AlarmManager with setAndAllowWhileIdle () to schedule the process, and that should be enough to fire even during dose mode, as described here . In addition, we found out that on some devices, such as Xiaomi and Huawei devices, there is a known issue of Push Notifications not working and background services not working and we are handling it. But the problem still persists across different types of devices and versions of Android.

Any ideas for this reason might come up? Thank!

+3


source to share


1 answer


The system sometimes kills the service when memory is low.

In the background, override the service onStartCommand()

and return START_STICKY

as a result.



It will tell the system that even if it wants to kill your service due to low memory, it should recreate it as soon as memory is back to normal.

+1


source







All Articles