0

I am successfully able to monitor new app installation by dynamically registering broadcast in foreground service for Oreo and above version. But for this I always have to show a persistent notification of my app. Is there any alternative to

Google in documentation says:

You should only use a foreground service when your app needs to perform a task that is noticeable by the user even when they're not directly interacting with the app. For this reason, foreground services must show a status bar notification with a priority of PRIORITY_LOW or higher, which helps ensure that the user is aware of what your app is doing. If the action is of low enough importance that you want to use a minimum-priority notification, you probably shouldn't be using a service; instead, consider using a scheduled job.

So can I use foreground service for this purpose. If not than what is its alternative.

Anis Khan
  • 61
  • 1
  • 8

1 Answers1

0

As said in the doc you posted, consider using a scheduled job.

if you use a foreground service you will need a constant notification and that would be annoying for the user (plus you don't install new package every five minutes so ...)

Instead you should schedule a job to check if a new package is installed.

Look at the accepted answer in this question

You can also use polling, setting up a JobScheduler job to check every so often, asking PackageManager for what has changed in the roster of installed apps via getChangedPackages().

Kilarn123
  • 723
  • 5
  • 6