Context.StopService(Intent) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Request that a given application service be stopped.
[Android.Runtime.Register("stopService", "(Landroid/content/Intent;)Z", "GetStopService_Landroid_content_Intent_Handler")]
public abstract bool StopService (Android.Content.Intent? service);
[<Android.Runtime.Register("stopService", "(Landroid/content/Intent;)Z", "GetStopService_Landroid_content_Intent_Handler")>]
abstract member StopService : Android.Content.Intent -> bool
Parameters
- service
- Intent
Description of the service to be stopped. The Intent must be either fully explicit (supplying a component name) or specify a specific package name it is targeted to.
Returns
If there is a service matching the given Intent that is already
running, then it is stopped and true
is returned; else false
is returned.
- Attributes
Exceptions
Remarks
Request that a given application service be stopped. If the service is not running, nothing happens. Otherwise it is stopped. Note that calls to startService() are not counted -- this stops the service no matter how many times it was started.
If the service is running as a foreground service when it is stopped, its associated notification will be removed. To avoid this, apps can use android.app.Service#stopForeground(int) stopForeground(STOP_FOREGROUND_DETACH)
to decouple the notification from the service's lifecycle before stopping it.
Note that if a stopped service still has ServiceConnection
objects bound to it with the #BIND_AUTO_CREATE
set, it will not be destroyed until all of these bindings are removed. See the android.app.Service
documentation for more details on a service's lifecycle.
This function will throw SecurityException
if you do not have permission to stop the given service.
Java documentation for android.content.Context.stopService(android.content.Intent)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.