Service.StopForeground 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| StopForeground(StopForegroundFlags) |
从前台状态中删除此服务,以便在需要更多内存时将其终止。 |
| StopForeground(Boolean) |
旧版的 |
StopForeground(StopForegroundFlags)
从前台状态中删除此服务,以便在需要更多内存时将其终止。
[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
参数
- flags
- StopForegroundFlags
选择删除或分离的通知行为标志;零请求旧处理。
- 特性
注解
从前台状态中删除此服务,以便在需要更多内存时将其终止。 这不会阻止服务运行(为此使用 stopSelf()或相关方法),只需将其从前台状态中取出。 如果提供了STOP_FOREGROUND_REMOVE,服务关联的通知将立即取消。
如果提供STOP_FOREGROUND_DETACH,则服务与通知的关联将被切断。 如果由于前台服务通知延迟策略尚未显示通知,则会在调用 stopForeground(STOP_FOREGROUND_DETACH)时立即发布通知。 在所有情况下,即使此服务完全停止并销毁,通知也会保持显示状态。
如果零作为参数传递,则结果将是 Android L 之前定义的旧行为:通知将一直发布,直到服务完全停止,此时会自动取消通知。
Android 参考。android.app.Service.stopForeground
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。
适用于
StopForeground(Boolean)
旧版的 #stopForeground(int).
[Android.Runtime.Register("stopForeground", "(Z)V", "")]
public void StopForeground(bool removeNotification);
[<Android.Runtime.Register("stopForeground", "(Z)V", "")>]
member this.StopForeground : bool -> unit
参数
- removeNotification
- Boolean
如果为 true, #STOP_FOREGROUND_REMOVE 则选择器将传递给 #stopForeground(int);否则 #STOP_FOREGROUND_LEGACY 将传递。
- 特性
注解
此方法在 API 级别 33 中已弃用。 调用 stopForeground(int),并显式传递STOP_FOREGROUND_REMOVE或STOP_FOREGROUND_DETACH。
stopForeground(int)的旧版本。
Android 参考。android.app.Service.stopForeground
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。