语言

PendingIntent.GetForegroundService 方法

定义

检索将启动前台服务的 PendingIntent,例如调用 Context#startForegroundService Context.startForegroundService()。

[Android.Runtime.Register("getForegroundService", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;", "", ApiSince=26)]
public static Android.App.PendingIntent? GetForegroundService(Android.Content.Context? context, int requestCode, Android.Content.Intent intent, Android.App.PendingIntentFlags flags);
[<Android.Runtime.Register("getForegroundService", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;", "", ApiSince=26)>]
static member GetForegroundService : Android.Content.Context * int * Android.Content.Intent * Android.App.PendingIntentFlags -> Android.App.PendingIntent

参数

context
Context

此 PendingIntent 应在其中启动服务的上下文。

requestCode
Int32

发件人的专用请求代码

intent
Intent

描述要启动的服务的意向。

flags
PendingIntentFlags

可以是#FLAG_ONE_SHOT、#FLAG_NO_CREATE、#FLAG_CANCEL_CURRENT#FLAG_UPDATE_CURRENT或#FLAG_IMMUTABLE受支持Intent#fillIn Intent.fillIn()的任何标志,用于控制实际发送发生时可以提供哪些未指定的意向部分。

返回

返回与给定参数匹配的现有或新的 PendingIntent。 仅当已提供时 #FLAG_NO_CREATE ,才能返回 null。

特性

注解

检索将启动前台服务的 PendingIntent,例如调用 Context.startForegroundService()。 提供给服务的起始参数来自意向的额外参数。 出于安全原因,此处提供的意向应几乎始终是显式意向,该意向指定要通过 Intent.setClass 传送到的显式组件

Android 参考。android.app.PendingIntent.getForegroundService

本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。

适用于