Home » Android » Do Android services using startForeground impact Play Store auto updates?

Do Android services using startForeground impact Play Store auto updates?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m using startForeground to run a service in my app. Does this impact Play Store auto updates when it’s running? It seems like it does because I’ll release a new version and a test tablet will still be running the old one for days after the release. The app shows “pending update” in Google Play on the device.

As background, this is not a normal consumer app and does need to run all the time to sync data. Without the foreground service I found even persistent alarms would stop running in a timely fashion after a few days, so as far as I’m aware, startForeground is the only way to keep the app running permanently.

Thanks for reading!

How to&Answers:

You can create an application which the Android system puts under whitelist application.

Under certain circumstances, a background app is placed on a temporary whitelist for several minutes. While an app is on the whitelist, it can launch services without limitation, and its background services are permitted to run.

An app is placed on the whitelist when it handles a task that’s visible to the user, such as:

  • Handling a high-priority Firebase Cloud Messaging (FCM) message.
  • Receiving a broadcast, such as an SMS/MMS message.
  • Executing a PendingIntent from a notification.
  • Starting a VpnService before the VPN app promotes itself to the
    foreground.

So you can create a high-priority FCM message for your update and send it as an update notification or just a blank message.

Set Up a Firebase Cloud Messaging Client App on Android