Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

will stopService() stop a foreground service?

Will stopService() stop a service running as a foreground service? It appears to, but also "feels" like it trumps the importance of foreground services.

like image 522
donfede Avatar asked Nov 29 '12 01:11

donfede


People also ask

How do you stop a foreground service?

The service must stop itself by calling stopSelf(), or another component can stop it by calling stopService(). Once requested to stop with stopSelf() or stopService(), the system destroys the service as soon as possible.

How do I stop foreground app from running?

In various older versions of Android, you can tap Settings > Apps or Settings > Applications > Application manager, and tap on an app and tap Force stop. In Android 10, the sequence is Settings > Apps & notifications > App info > [App name] > Disable or Force stop.

What does it mean when it says app is using foreground service?

A foreground service performs some operation that is noticeable to the user. For example, an audio app would use a foreground service to play an audio track. Foreground services must display a Notification. Foreground services continue running even when the user isn't interacting with the app.


2 Answers

Confirmed: Yes - running stopService() from an Activity outside of the service will stop the service -- even if the service is a foreground running service.

like image 96
donfede Avatar answered Oct 27 '22 07:10

donfede


It stops the service outright. It doesn't trump any importance, if your code is sending an Intent to stop the service, it would make perfect sense to obey said Intent.

like image 22
A--C Avatar answered Oct 27 '22 07:10

A--C