I Want To Schedule A Worker To Show A Notification When The Device Is Plugged In And Connected To The Internet
Alright, I think the title is pretty self-explanatory...I have to use the WorkManager api to schedule a notification that will be displayed every time the device is connected to th
Solution 1:
I don't think that WorkManager is the best option in this case.
In your particular case, you are using a OneTimeWorkRequest
so, once this is run by the WorkManager, you need to enqueue it again (but it becomes tricky to enqueue it only when one of the two contrastraints are false).
A better approach would be to use a combination of the BatteryManager
and the ConnectivityManager
.
Post a Comment for "I Want To Schedule A Worker To Show A Notification When The Device Is Plugged In And Connected To The Internet"