Service.StopForeground Method

Definition

Overloads

Name Description
StopForeground(StopForegroundFlags)

Remove this service from foreground state, allowing it to be killed if more memory is needed.

StopForeground(Boolean)

This method was deprecated in API level 33.

StopForeground(StopForegroundFlags)

Remove this service from foreground state, allowing it to be killed if more memory is needed.

[Android.Runtime.Register("stopForeground", "(I)V", "", ApiSince=24)]
public void StopForeground(Android.App.StopForegroundFlags flags);
[<Android.Runtime.Register("stopForeground", "(I)V", "", ApiSince=24)>]
member this.StopForeground : Android.App.StopForegroundFlags -> unit

Parameters

Attributes

Remarks

Remove this service from foreground state, allowing it to be killed if more memory is needed. This does not stop the service from running (for that you use stopSelf() or related methods), just takes it out of the foreground state. If STOP_FOREGROUND_REMOVE is supplied, the service's associated notification will be cancelled immediately.

If STOP_FOREGROUND_DETACH is supplied, the service's association with the notification will be severed. If the notification had not yet been shown, due to foreground-service notification deferral policy, it is immediately posted when stopForeground(STOP_FOREGROUND_DETACH) is called. In all cases, the notification remains shown even after this service is stopped fully and destroyed.

If zero is passed as the argument, the result will be the legacy behavior as defined prior to Android L: the notification will remain posted until the service is fully stopped, at which time it will automatically be cancelled.

See also:

Android reference for android.app.Service.stopForeground.

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.

Applies to

StopForeground(Boolean)

This method was deprecated in API level 33.

[Android.Runtime.Register("stopForeground", "(Z)V", "")]
public void StopForeground(bool removeNotification);
[<Android.Runtime.Register("stopForeground", "(Z)V", "")>]
member this.StopForeground : bool -> unit

Parameters

removeNotification
Boolean

boolean: If true, the STOP_FOREGROUND_REMOVE selector will be passed to stopForeground(int); otherwise STOP_FOREGROUND_LEGACY will be passed.

Attributes

Remarks

This method was deprecated in API level 33. call stopForeground(int) and pass either STOP_FOREGROUND_REMOVE or STOP_FOREGROUND_DETACH explicitly instead.

Legacy version of stopForeground(int).

See also:

Android reference for android.app.Service.stopForeground.

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.

Applies to