Objective Observe the SMS Content Provider to keep track of Sent SMS and notify the user when they reach a certain limit.
What works:
- Targeting API 22, I started a (
START_STICKY
) background service which initialized a ContentObserver that listens to SMS URI changes. - Since Oreo doesn't allow background services, I changed this to a foregroundService that shows a persistent notification that a service is running but works as expected. (Running a normal background service, it gets stopped after around 1 minute when the parent activity is left idle)
Running on Oreo
While reading through many articles, I could find out stuff like JobIntentService
which can perform a task in the background and then finish. Since I need the ContentObserver to run always or at least when the device is woken up, is there any preferred way to accomplish this.
The persistent notification has made even me to stop the service as it looks annoying.