Aracılığıyla paylaş


Service.StopForeground Method

Definition

Overloads

StopForeground(StopForegroundFlags)

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

StopForeground(Boolean)

Legacy version of #stopForeground(int).

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

flags
StopForegroundFlags

additional behavior options.

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.

Java documentation for android.app.Service.stopForeground(int).

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)

Legacy version of #stopForeground(int).

[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

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

Attributes

Remarks

Legacy version of #stopForeground(int).

This member is deprecated. call #stopForeground(int) and pass either #STOP_FOREGROUND_REMOVE or #STOP_FOREGROUND_DETACH explicitly instead.

Java documentation for android.app.Service.stopForeground(boolean).

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.

See also

  • <xref:Android.App.Service.StartForeground(System.Int32%2c+Android.App.Notification)>

Applies to