So I\'m not sure where/how to implement this method to make my service run in the foreground. Currently I start my service by the following in another activity:
<
Note: If your app targets API level 26 or higher, the system imposes restrictions on using or creating background services unless the app itself is in the foreground.
If an app needs to create a foreground service, the app should call startForegroundService()
. That method creates a background service, but the method signals to the system that the service will promote itself to the foreground.
Once the service has been created, the service must call its startForeground() method within five seconds.