androidandroid-serviceandroid-jetpackandroid-workmanagerandroid-service-binding

Should I use a workmanager for an immediate work without showing notification


Let's say my application has several activities. When I come to the first activity, I will initiate an api call. User won't be blocked during this api call and can navigate to other activities during this time.The status of this api call can be observed by any activity that is in foreground. After api success, data will be populated on the current activity. We can use a service for this and bind the foreground activity to the service. But can we use a workmanager for this? I see that workmanager is designed for deferrable works. Can we use it for immediate works like making an api call to populate the ui without showing notification to the user? I don't want to show any notification to the user, as api call will only occur while application is in foreground.


Solution

  • https://www.youtube.com/watch?v=kpuMD2P7s5M says work manager does support immediate work. So I think it's safe to use workmanager.