语言

PendingIntent.GetService(Context, Int32, Intent, PendingIntentFlags) 方法

定义

检索将启动服务(如调用 Context#startService Context.startService())的 PendingIntent。

[Android.Runtime.Register("getService", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;", "")]
public static Android.App.PendingIntent? GetService(Android.Content.Context? context, int requestCode, Android.Content.Intent intent, Android.App.PendingIntentFlags flags);
[<Android.Runtime.Register("getService", "(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;", "")>]
static member GetService : 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.startService()。 提供给服务的起始参数来自意向的额外参数。 出于安全原因,此处提供的意向应几乎始终是显式意向,该意向指定要通过 Intent.setClass 传送到的显式组件

Android 参考。android.app.PendingIntent.getService

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

适用于