Share via


Service 类

定义

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

[Android.Runtime.Register("android/app/Service", DoNotGenerateAcw=true)]
public abstract class Service : Android.Content.ContextWrapper, Android.Content.IComponentCallbacks2, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/app/Service", DoNotGenerateAcw=true)>]
type Service = class
    inherit ContextWrapper
    interface IComponentCallbacks
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IComponentCallbacks2
继承
派生
属性
实现

注解

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。 每个服务类在其包的 AndroidManifest.xml中必须具有相应的android.R.styleable#AndroidManifestService &lt;service&gt;声明。 服务可以使用 和 android.content.Context#bindService Context.bindService()启动android.content.Context#startService Context.startService()

请注意,与其他应用程序对象一样,服务在其宿主进程的main线程中运行。 这意味着,如果服务要执行任何 CPU 密集型 ((例如 MP3 播放) 或阻止 ((如网络) 操作),它应生成自己的线程,在其中执行该工作。 有关此方面的详细信息,请参阅 进程和线程。 类 androidx.core.app.JobIntentService 作为 Service 的标准实现提供,Service 具有自己的线程,可在其中计划完成其工作。

此处涵盖的主题: <ol><li>什么是服务?<li>Service Lifecycle<li>Permissions<li>Process Lifecycle<li>Local Service Sample<li>Remote Messenger Service Sample</ol>

<div class=“special reference”><h3>Developer Guides</h3>

有关如何创建服务的详细讨论,请阅读 服务 开发人员指南。

</Div>

“WhatIsAService”><h3>什么是服务?</h3>

有关 Service 类的大多数混淆实际上都围绕它不是<></em:>

<ul><li> A 服务是<一><>个单独的进程。 Service 对象本身并不表示它在其自己的进程中运行;除非另有指定,否则它在与它所属的应用程序相同的进程中运行。 <li> A 服务是 <b>不是<>线程。 它本身并不是在main线程 (执行工作以避免应用程序未响应错误) 。 </ul>

因此,服务本身实际上非常简单,提供两个main功能:

<ul><li>一个工具,用于告知系统 <em><> 它希望在后台 (执行的操作,即使用户未直接与应用程序) 交互也是如此。 这对应于对 android.content.Context#startService Context.startService()的调用,该调用要求系统计划服务的工作,直到服务或其他人显式停止它为止。 <li>应用程序向其他应用程序公开其某些功能的工具。 这对应于对 android.content.Context#bindService Context.bindService()的调用,后者允许与服务建立长期连接,以便与其交互。 </ul>

当实际创建服务组件时,出于上述任一原因,系统实际执行的所有操作就是实例化该组件,并在main线程上调用其#onCreate和任何其他适当的回调。 由服务以适当的行为实现这些操作,例如创建辅助线程以执行其工作。

请注意,由于服务本身非常简单,因此可以根据需要使其交互变得简单或复杂:从将其视为对 (进行直接方法调用的本地 Java 对象(如本地服务示例) 所示),到使用 AIDL 提供完整的可远程接口。

“ServiceLifecycle”><h3>服务生命周期</h3>

服务可由系统运行有两个原因。 如果有人调用 android.content.Context#startService Context.startService() ,则系统将检索服务 (创建服务并在需要时调用其 #onCreate 方法) 然后使用客户端提供的参数调用其 #onStartCommand 方法。 此时,服务将继续运行,直到 android.content.Context#stopService Context.stopService() 调用 或 #stopSelf() 。 请注意,对 Context.startService () 的多次调用不会嵌套 (尽管它们会导致对 onStartCommand () ) 进行多次相应的调用,因此无论启动多少次,在调用 Context.stopService () 或 stopSelf () 后,服务都将停止;但是,服务可以使用其 #stopSelf(int) 方法来确保服务在处理启动的意向之前不会停止。

对于已启动的服务,有两种其他主要操作模式可以决定运行,具体取决于它们从 onStartCommand () 返回的值: #START_STICKY 用于根据需要显式启动和停止的服务,而 #START_NOT_STICKY#START_REDELIVER_INTENT 用于只应在处理发送给它们的命令时保持运行的服务。 有关语义的更多详细信息,请参阅链接的文档。

客户端还可以使用 android.content.Context#bindService Context.bindService() 获取到服务的持久连接。 如果服务尚未运行 () 调用 #onCreate ,但不会调用 onStartCommand () ,则同样会创建该服务。 客户端将接收 android.os.IBinder 服务从其 #onBind 方法返回的对象,从而允许客户端随后调用回服务。 只要建立连接 (客户端是否保留对服务的 IBinder) 的引用,服务就会保持运行状态。 通常,返回的 IBinder 适用于以 aidl 编写的复杂接口。

服务既可以启动,也可以有绑定到它的连接。 在这种情况下,只要服务启动<><或/或>有一个或多个带有 android.content.Context#BIND_AUTO_CREATE Context.BIND_AUTO_CREATE 标志的连接,系统就会保持服务运行。 一旦这两种情况都不成立,就会调用服务的 #onDestroy 方法,并且服务将有效地终止。 从 onDestroy () 返回后,所有清理 (停止线程、取消注册接收方) 应完成。

“Permissions”><h3>Permissions</h3>

当服务在其清单的 android.R.styleable#AndroidManifestService &lt;service&gt; 标记中声明时,可以强制对其进行全局访问。 通过这样做,其他应用程序将需要在其自己的清单中声明相应的 android.R.styleable#AndroidManifestUsesPermission &lt;uses-permission&gt; 元素,以便能够启动、停止或绑定到服务。

在使用 android.os.Build.VERSION_CODES#GINGERBREADContext#startService(Intent) Context.startService(Intent),还可以在意向上设置 Intent#FLAG_GRANT_READ_URI_PERMISSION Intent.FLAG_GRANT_READ_URI_PERMISSION 和/或 Intent#FLAG_GRANT_WRITE_URI_PERMISSION Intent.FLAG_GRANT_WRITE_URI_PERMISSION 。 这将授予服务对意向中特定 URI 的临时访问权限。 访问将一直保留,直到服务为该启动命令或之后的启动命令调用 #stopSelf(int) ,或者直到服务完全停止为止。 这适用于授予其他应用的访问权限,这些应用未请求保护服务的权限,甚至根本不导出服务时也是如此。

此外,服务可以通过在执行该调用的实现之前调用 #checkCallingPermission 方法,使用权限保护对它的单个 IPC 调用。

有关 权限和安全性 的一般详细信息,请参阅安全和权限文档。

“ProcessLifecycle”><h3>进程生命周期</h3>

只要服务已启动或有绑定到它的客户端,Android 系统将尝试使承载服务的进程保持在周围。 当内存不足且需要终止现有进程时,承载服务的进程的优先级将高于以下可能性:

<ul><li>

如果服务当前正在执行其 #onCreate onCreate()#onStartCommand onStartCommand()#onDestroy onDestroy() 方法中的代码,则宿主进程将是一个前台进程,以确保此代码可以在不终止的情况下执行。 <李>

如果服务已启动,则其托管进程被认为不如屏幕上用户当前可见的任何进程重要,但比任何不可见的进程更重要。 由于通常只有少数进程对用户可见,这意味着不应终止服务,除非在内存不足的情况下。 但是,由于用户不直接知道后台服务,因此在该状态下,它<><>被视为要终止的有效候选项,因此你应该为此做好准备。 特别是,长时间运行的服务将越来越可能终止,并保证在适当的情况下 (终止并重启) 如果服务启动时间足够长。 <李>

如果存在绑定到服务的客户端,则服务的托管进程永远不会比最重要的客户端重要。 也就是说,如果其中一个客户端对用户可见,则服务本身被视为可见。 客户端的重要性影响服务重要性的方式可以通过 、、Context#BIND_ALLOW_OOM_MANAGEMENTContext#BIND_WAIVE_PRIORITYContext#BIND_IMPORTANT、 和 Context#BIND_ADJUST_WITH_ACTIVITY进行调整Context#BIND_ABOVE_CLIENT。 <李>

启动的服务可以使用 #startForeground(int, Notification) API 将服务置于前台状态,其中系统将其视为用户主动意识到的内容,因此不会在内存不足时将其视为终止的候选项。 (理论上,在当前前台应用程序的极端内存压力下,服务仍有可能终止,但实际上这不应引起关注。) </ul>

请注意,这意味着大多数情况下,如果服务在内存压力过大的情况下,系统可能会终止该服务。 如果发生这种情况,系统将稍后尝试重启服务。 其一个重要后果是,如果实现 #onStartCommand onStartCommand() 以计划以异步方式或在另一个线程中完成的工作,则你可能希望使用 #START_FLAG_REDELIVERY 让系统为你重新传递意向,以便在处理服务时终止服务时不会丢失它。

当然,在与服务 (相同的进程中运行的其他应用程序组件(如 android.app.Activity) )可以增加整个进程的重要性,而不仅仅是服务本身的重要性。

“LocalServiceSample”><h3>本地服务示例</h3>

服务最常见的用途之一是作为辅助组件与应用程序的其他部分一起运行,与其余组件在同一进程中运行。 除非另有明确说明,否则 .apk 的所有组件都在同一进程中运行,因此这是一种典型情况。

以这种方式使用时,假设组件位于同一进程中,可以大大简化它们之间的交互:服务的客户端只需将他们从组件接收的 IBinder 强制转换为服务发布的具体类。

此处显示了服务的此用法示例。 首先是服务本身,在绑定时发布自定义类:

{

android.app.ServiceJava 文档。

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

构造函数

Service()
Service(IntPtr, JniHandleOwnership)

创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。

字段

AccessibilityService

使用 和 #getSystemService(String) 检索 , android.view.accessibility.AccessibilityManager 以便通过已注册的事件侦听器向用户提供 UI 事件反馈。

(继承自 Context)
AccountService

使用 和 #getSystemService(String) 检索 , android.accounts.AccountManager 以便在选择时接收意向。

(继承自 Context)
ActivityService

使用 和 #getSystemService(String) 检索 用于 android.app.ActivityManager 与全局系统状态交互的 。

(继承自 Context)
AlarmService

使用 和 #getSystemService(String) 检索 , android.app.AlarmManager 以便在选择时接收意向。

(继承自 Context)
AppOpsService

使用 和 #getSystemService(String) 检索 , android.app.AppOpsManager 以跟踪设备上的应用程序操作。

(继承自 Context)
AppSearchService

使用 和 #getSystemService(String) 检索 , android.app.appsearch.AppSearchManager 以便为系统管理的应用数据编制索引和查询。

(继承自 Context)
AppwidgetService

使用 和 #getSystemService(String) 检索 用于 android.appwidget.AppWidgetManager 访问 AppWidgets 的 。

(继承自 Context)
AudioService

使用 和 #getSystemService(String) 检索 , android.media.AudioManager 以处理音量、响铃模式和音频路由的管理。

(继承自 Context)
BatteryService

使用 和 #getSystemService(String) 检索 用于 android.os.BatteryManager 管理电池状态的 。

(继承自 Context)
BindAllowActivityStarts
已过时.

标志 #bindService:如果从可见的应用绑定,则允许绑定服务从后台启动活动。

(继承自 Context)
BindExternalServiceLong

的工作方式与 相同 #BIND_EXTERNAL_SERVICE,但它被定义为 (

(继承自 Context)
BindNotPerceptible
已过时.

标志 #bindService:如果从可见或用户可感知的应用绑定,请将目标服务的重要性降低到可感知级别以下。

(继承自 Context)
BindSharedIsolatedProcess
已过时.

标志 #bindIsolatedService:将服务绑定到共享隔离进程。

(继承自 Context)
BiometricService

与 配合使用 #getSystemService(String) 以检索 用于 android.hardware.biometrics.BiometricManager 处理生物识别和 PIN/模式/密码身份验证的 。

(继承自 Context)
BlobStoreService

使用 和 #getSystemService(String) 检索 , android.app.blob.BlobStoreManager 以便从系统维护的 Blob 存储中提供和访问数据 Blob。

(继承自 Context)
BluetoothService

使用 和 #getSystemService(String) 检索以 android.bluetooth.BluetoothManager 使用蓝牙。

(继承自 Context)
BugreportService

用于捕获 bug 报告的服务。

(继承自 Context)
CameraService

使用 来 #getSystemService(String) 检索 , android.hardware.camera2.CameraManager 以便与相机设备交互。

(继承自 Context)
CaptioningService

使用 和 #getSystemService(String) 检索 , android.view.accessibility.CaptioningManager 以获取字幕属性并侦听字幕首选项的更改。

(继承自 Context)
CarrierConfigService

使用 和 #getSystemService(String) 检索 以 android.telephony.CarrierConfigManager 读取运营商配置值。

(继承自 Context)
ClipboardService

使用 和 #getSystemService(String) 检索 , android.content.ClipboardManager 以访问和修改全局剪贴板的内容。

(继承自 Context)
CompanionDeviceService

使用 和 #getSystemService(String) 检索 , android.companion.CompanionDeviceManager 以管理配套设备

(继承自 Context)
ConnectivityDiagnosticsService

使用 和 #getSystemService(String) 检索 ,android.net.ConnectivityDiagnosticsManager以执行网络连接诊断以及从系统接收网络连接信息。

(继承自 Context)
ConnectivityService

使用 和 #getSystemService(String) 检索 , android.net.ConnectivityManager 以处理网络连接的管理。

(继承自 Context)
ConsumerIrService

使用 和 #getSystemService(String) 检索 用于 android.hardware.ConsumerIrManager 从设备传输红外信号的 。

(继承自 Context)
CredentialService

使用 和 #getSystemService(String) 检索 , android.credentials.CredentialManager 以向应用验证用户身份。

(继承自 Context)
CrossProfileAppsService

使用 和 #getSystemService(String) 检索 android.content.pm.CrossProfileApps 交叉配置文件操作的 。

(继承自 Context)
DeviceIdDefault

默认设备 ID,即主 (非虚拟) 设备的 ID。

(继承自 Context)
DeviceIdInvalid

设备 ID 无效。

(继承自 Context)
DeviceLockService

将 与 一起使用#getSystemService(String)android.devicelock.DeviceLockManager以检索 。

(继承自 Context)
DevicePolicyService

使用 来 #getSystemService(String) 检索 , android.app.admin.DevicePolicyManager 以使用全局设备策略管理。

(继承自 Context)
DisplayHashService

使用 和 #getSystemService(String) 访问 android.view.displayhash.DisplayHashManager 以处理显示哈希。

(继承自 Context)
DisplayService

使用 来 #getSystemService(String) 检索 用于 android.hardware.display.DisplayManager 与显示设备交互的 。

(继承自 Context)
DomainVerificationService

使用 和 #getSystemService(String) 访问 android.content.pm.verify.domain.DomainVerificationManager ,以检索已声明 Web 域的审批和用户状态。

(继承自 Context)
DownloadService

使用 和 #getSystemService(String) 检索 用于 android.app.DownloadManager 请求 HTTP 下载的 。

(继承自 Context)
DropboxService

使用 和 #getSystemService(String) 检索用于记录诊断日志的 android.os.DropBoxManager 实例。

(继承自 Context)
EuiccService

使用 和 #getSystemService(String) 检索 , android.telephony.euicc.EuiccManager 以管理设备 eUICC (嵌入式 SIM) 。

(继承自 Context)
FileIntegrityService

将 与 配合使用 #getSystemService(String) 以检索 android.security.FileIntegrityManager

(继承自 Context)
FingerprintService

使用 和 #getSystemService(String) 检索 , android.hardware.fingerprint.FingerprintManager 以处理指纹管理。

(继承自 Context)
GameService

将 与 一起使用#getSystemService(String)GameManager以检索 。

(继承自 Context)
GrammaticalInflectionService

将 与 一起使用#getSystemService(String)GrammaticalInflectionManager以检索 。

(继承自 Context)
HardwarePropertiesService

使用 和 #getSystemService(String) 检索 用于 android.os.HardwarePropertiesManager 访问硬件属性服务的 。

(继承自 Context)
HealthconnectService

将 与 一起使用#getSystemService(String)android.health.connect.HealthConnectManager以检索 。

(继承自 Context)
InputMethodService

使用 和 #getSystemService(String) 检索 用于 android.view.inputmethod.InputMethodManager 访问输入法的 。

(继承自 Context)
InputService

使用 来 #getSystemService(String) 检索 , android.hardware.input.InputManager 以便与输入设备交互。

(继承自 Context)
IpsecService

使用 和 #getSystemService(String) 检索 , android.net.IpSecManager 以使用 IPSec 加密套接字或网络。

(继承自 Context)
JobSchedulerService

使用 和 #getSystemService(String) 检索 android.app.job.JobScheduler 用于管理偶尔后台任务的实例。

(继承自 Context)
KeyguardService

使用 和 #getSystemService(String) 检索 用于 android.app.KeyguardManager 控制键保护的 。

(继承自 Context)
LauncherAppsService

使用 和 #getSystemService(String) 检索 , android.content.pm.LauncherApps 以便跨用户的配置文件查询和监视可启动的应用。

(继承自 Context)
LayoutInflaterService

使用 和 #getSystemService(String) 检索 , android.view.LayoutInflater 以便在此上下文中扩充布局资源。

(继承自 Context)
LocaleService

将 与 一起使用#getSystemService(String)android.app.LocaleManager以检索 。

(继承自 Context)
LocationService

使用 和 #getSystemService(String) 检索 , android.location.LocationManager 以控制位置更新。

(继承自 Context)
MediaCommunicationService

将 与 配合使用 #getSystemService(String) 来检索android.media.MediaCommunicationManager 用于管理 android.media.MediaSession2

(继承自 Context)
MediaMetricsService

使用 和 #getSystemService(String) 检索 , android.media.metrics.MediaMetricsManager 以便与设备上的媒体指标交互。

(继承自 Context)
MediaProjectionService

使用 和 #getSystemService(String) 检索 android.media.projection.MediaProjectionManager 用于管理媒体投影会话的实例。

(继承自 Context)
MediaRouterService

使用 和 #getSystemService 检索 , android.media.MediaRouter 以控制和管理媒体的路由。

(继承自 Context)
MediaSessionService

使用 和 #getSystemService(String) 检索 用于 android.media.session.MediaSessionManager 管理媒体会话的 。

(继承自 Context)
MidiService

使用 和 #getSystemService(String) 检索 用于 android.media.midi.MidiManager 访问 MIDI 服务的 。

(继承自 Context)
NetworkStatsService

使用 和 #getSystemService(String) 检索 用于 android.app.usage.NetworkStatsManager 查询网络使用情况统计信息的 。

(继承自 Context)
NfcService

使用 和 #getSystemService(String) 检索以 android.nfc.NfcManager 使用 NFC。

(继承自 Context)
NotificationService

使用 和 #getSystemService(String) 检索 , android.app.NotificationManager 以通知用户后台事件。

(继承自 Context)
NsdService

使用 和 #getSystemService(String) 检索 用于 android.net.nsd.NsdManager 处理网络服务发现的管理

(继承自 Context)
OverlayService

使用 和 #getSystemService(String) 检索 用于 android.content.om.OverlayManager 管理覆盖包的 。

(继承自 Context)
PeopleService

使用 访问 #getSystemService(String)PeopleManager 以便与已发布的对话进行交互。

(继承自 Context)
PerformanceHintService

使用 和 #getSystemService(String) 检索 , android.os.PerformanceHintManager 以访问性能提示服务。

(继承自 Context)
PowerService

与 一起使用 #getSystemService(String) 以检索 android.os.PowerManager 用于控制电源管理的 ,包括“唤醒锁”,使你可以在运行长时间任务时使设备保持打开状态。

(继承自 Context)
PrintService

android.print.PrintManager 用于打印和管理打印机和打印任务。

(继承自 Context)
ReceiverExported
已过时.

标志 #registerReceiver:接收方可以从其他应用接收广播。

(继承自 Context)
ReceiverNotExported
已过时.

标志 #registerReceiver:接收方无法接收来自其他应用的广播。

(继承自 Context)
ReceiverVisibleToInstantApps
已过时.

标志 #registerReceiver:接收方可以从即时应用接收广播。

(继承自 Context)
RestrictionsService

使用 和 #getSystemService(String) 检索 用于 android.content.RestrictionsManager 检索应用程序限制和请求受限操作的权限。

(继承自 Context)
RoleService

使用 和 #getSystemService(String) 检索 用于 android.app.role.RoleManager 管理角色的 。

(继承自 Context)
SearchService

使用 和 #getSystemService(String) 检索用于 android.app.SearchManager 处理搜索的 。

(继承自 Context)
SensorService

使用 和 #getSystemService(String) 检索 用于 android.hardware.SensorManager 访问传感器的 。

(继承自 Context)
ShortcutService

使用 和 #getSystemService(String) 检索 用于 android.content.pm.ShortcutManager 访问启动器快捷方式服务的 。

(继承自 Context)
StatusBarService

使用 来 #getSystemService(String) 检索 , android.app.StatusBarManager 以便与状态栏和快速设置交互。

(继承自 Context)
StopForegroundDetach
已过时.

选择 #stopForeground(int)器 : 如果已设置,先前提供给 #startForeground 的通知将从服务的生命周期中分离。

StopForegroundLegacy

的选择器 #stopForeground(int): 等效于传递给 false 旧 API #stopForeground(boolean)

StopForegroundRemove
已过时.

选择器 #stopForeground(int): 如果已提供,则之前提供给 #startForeground 的通知将取消并从显示中删除。

StorageService

使用 和 #getSystemService(String) 检索 用于 android.os.storage.StorageManager 访问系统存储函数的 。

(继承自 Context)
StorageStatsService

使用 和 #getSystemService(String) 检索 用于 android.app.usage.StorageStatsManager 访问系统存储统计信息的 。

(继承自 Context)
SystemHealthService

与 配合使用 #getSystemService(String) 以检索 android.os.health.SystemHealthManager 用于访问系统运行状况 (电池、电源、内存等) 指标。

(继承自 Context)
TelecomService

使用 和 #getSystemService(String) 检索 , android.telecom.TelecomManager 以管理设备与电信相关的功能。

(继承自 Context)
TelephonyImsService

将 与 配合使用 #getSystemService(String) 以检索 android.telephony.ims.ImsManager

(继承自 Context)
TelephonyService

使用 和 #getSystemService(String) 检索 , android.telephony.TelephonyManager 以处理设备的电话功能管理。

(继承自 Context)
TelephonySubscriptionService

使用 和 #getSystemService(String) 检索 , android.telephony.SubscriptionManager 以处理设备的电话订阅的管理。

(继承自 Context)
TextClassificationService

使用 和 #getSystemService(String) 检索 TextClassificationManager 文本分类服务的 。

(继承自 Context)
TextServicesManagerService

使用 和 #getSystemService(String) 检索 以 android.view.textservice.TextServicesManager 访问文本服务。

(继承自 Context)
TvInputService

使用 来 #getSystemService(String) 检索 , android.media.tv.TvInputManager 以便与设备上的电视输入进行交互。

(继承自 Context)
TvInteractiveAppService

使用 和 #getSystemService(String) 检索 , android.media.tv.interactive.TvInteractiveAppManager 以便与设备上的电视交互式应用程序交互。

(继承自 Context)
UiModeService

使用 和 #getSystemService(String) 检索 用于 android.app.UiModeManager 控制 UI 模式的 。

(继承自 Context)
UsageStatsService

使用 和 #getSystemService(String) 检索 用于 android.app.usage.UsageStatsManager 查询设备使用情况统计信息的 。

(继承自 Context)
UsbService

使用 和 #getSystemService(String) 检索 android.hardware.usb.UsbManager 以访问 USB 设备 (作为 USB 主机) ,并控制此设备作为 USB 设备的行为。

(继承自 Context)
UserService

使用 和 #getSystemService(String) 检索 , android.os.UserManager 以在支持多个用户的设备上管理用户。

(继承自 Context)
VibratorManagerService

使用 来 #getSystemService(String) 检索 用于 android.os.VibratorManager 访问设备振动器、与单个振动器交互并在多个振动器上播放同步效果的 。

(继承自 Context)
VibratorService

使用 和 #getSystemService(String) 检索 用于 android.os.Vibrator 与振动硬件交互的 。

(继承自 Context)
VirtualDeviceService

使用 和 #getSystemService(String) 检索 用于 android.companion.virtual.VirtualDeviceManager 管理虚拟设备的 。

(继承自 Context)
VpnManagementService

使用 和 #getSystemService(String) 检索 , android.net.VpnManager 以管理平台内置 VPN 的配置文件。

(继承自 Context)
WallpaperService

使用 和 #getSystemService(String) 检索 com。

(继承自 Context)
WifiAwareService

使用 和 #getSystemService(String) 检索 , android.net.wifi.aware.WifiAwareManager 以处理 Wi-Fi Aware 的管理。

(继承自 Context)
WifiP2pService

使用 和 #getSystemService(String) 检索 , android.net.wifi.p2p.WifiP2pManager 以处理 Wi-Fi 对等连接的管理。

(继承自 Context)
WifiRttRangingService

使用 和 #getSystemService(String) 检索 android.net.wifi.rtt.WifiRttManager 具有 wifi 的测距设备的 。

(继承自 Context)
WifiService

使用 和 #getSystemService(String) 检索 , android.net.wifi.WifiManager 以处理 Wi-Fi 访问的管理。

(继承自 Context)
WindowService

使用 和 #getSystemService(String) 检索 用于 android.view.WindowManager 访问系统的窗口管理器的 。

(继承自 Context)

属性

Application

返回拥有此服务的应用程序。

ApplicationContext

返回当前进程的单个全局 Application 对象的上下文。

(继承自 ContextWrapper)
ApplicationInfo

返回此上下文包的完整应用程序信息。

(继承自 ContextWrapper)
Assets

返回应用程序的包的 AssetManager 实例。

(继承自 ContextWrapper)
AttributionSource

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
AttributionTag

可在复杂应用中使用归因,以逻辑方式分隔应用的各个部分。

(继承自 Context)
BaseContext (继承自 ContextWrapper)
CacheDir

返回文件系统上特定于应用程序的缓存目录的绝对路径。

(继承自 ContextWrapper)
Class

返回此 Object的运行时类。

(继承自 Object)
ClassLoader

返回可用于检索此包中的类的类加载程序。

(继承自 ContextWrapper)
CodeCacheDir

返回用于存储缓存代码的文件系统上特定于应用程序的缓存目录的绝对路径。

(继承自 ContextWrapper)
ContentResolver

返回应用程序包的 ContentResolver 实例。

(继承自 ContextWrapper)
DataDir

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
DeviceId

获取与此上下文关联的设备 ID。

(继承自 Context)
Display

获取与此上下文关联的显示。

(继承自 Context)
ExternalCacheDir

返回主外部文件系统 (目录的绝对路径,该目录位于应用程序可以放置其拥有的缓存文件的某个位置 ExternalStorageDirectory

(继承自 ContextWrapper)
FilesDir

返回文件系统上存储使用 OpenFileOutput(String, FileCreationMode) 创建的文件的目录的绝对路径。

(继承自 ContextWrapper)
ForegroundServiceType

如果服务已通过调用成为前台服务#startForeground(int, Notification)#startForeground(int, Notification, int)#getForegroundServiceType() 返回当前前台服务类型。

Handle

基础 Android 实例的句柄。

(继承自 Object)
IsDeviceProtectedStorage

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
IsRestricted

指示此上下文是否受到限制。

(继承自 Context)
IsUiContext

true如果上下文是可以访问 UI 组件(如 、 或 android.app.WallpaperManager WallpaperManagerWindowManager的 UI 上下文,android.view.LayoutInflater LayoutInflater则返回 。

(继承自 Context)
JniIdentityHashCode

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
JniPeerMembers

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

MainExecutor

返回一个 Executor ,它将在此上下文关联的main线程上运行排队任务。

(继承自 Context)
MainLooper

返回当前进程的main线程的 Looper。

(继承自 ContextWrapper)
NoBackupFilesDir

返回文件系统上目录的绝对路径,类似于 FilesDir

(继承自 ContextWrapper)
ObbDir

返回主外部存储目录,如果可以找到任何) ,则此应用程序的 OBB 文件 (。

(继承自 ContextWrapper)
OpPackageName

返回应用于 android.app.AppOpsManager 来自此上下文的调用的包名称,以便应用操作管理器的 uid 验证将使用该名称。

(继承自 Context)
PackageCodePath

返回此上下文的主 Android 包的完整路径。

(继承自 ContextWrapper)
PackageManager

返回 PackageManager 实例以查找全局包信息。

(继承自 ContextWrapper)
PackageName

返回此应用程序的包的名称。

(继承自 ContextWrapper)
PackageResourcePath

返回此上下文的主 Android 包的完整路径。

(继承自 ContextWrapper)
Params

返回创建此上下文时所使用的参数集(如果它是通过 #createContext(ContextParams)创建的)。

(继承自 Context)
PeerReference

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
Resources

返回应用程序包的 Resources 实例。

(继承自 ContextWrapper)
Theme

返回与此上下文关联的 Theme 对象。

(继承自 ContextWrapper)
ThresholdClass

此 API 支持 Mono for Android 基础结构,不应直接从代码使用。

ThresholdType

此 API 支持 Mono for Android 基础结构,不应直接从代码使用。

Wallpaper (继承自 ContextWrapper)
WallpaperDesiredMinimumHeight (继承自 ContextWrapper)
WallpaperDesiredMinimumWidth (继承自 ContextWrapper)

方法

AttachBaseContext(Context)

设置此 ContextWrapper 的基本上下文。

(继承自 ContextWrapper)
BindService(Intent, Bind, IExecutor, IServiceConnection)

#bindService(Intent, ServiceConnection, int) bindService(Intent, ServiceConnection, int) 用于控制 ServiceConnection 回调的执行程序相同。

(继承自 Context)
BindService(Intent, Context+BindServiceFlags, IExecutor, IServiceConnection)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
BindService(Intent, IServiceConnection, Bind)

连接到应用程序服务,根据需要创建它。

(继承自 ContextWrapper)
BindService(Intent, IServiceConnection, Context+BindServiceFlags)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
BindServiceAsUser(Intent, IServiceConnection, Context+BindServiceFlags, UserHandle)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
BindServiceAsUser(Intent, IServiceConnection, Int32, UserHandle)

以与 相同的方式#bindService绑定到给定 user 中的服务。

(继承自 Context)
CheckCallingOrSelfPermission(String)

确定 IPC 的调用过程或 是否已被授予特定权限。

(继承自 ContextWrapper)
CheckCallingOrSelfUriPermission(Uri, ActivityFlags)

确定 IPC 的调用过程或 是否已被授予访问特定 URI 的权限。

(继承自 ContextWrapper)
CheckCallingOrSelfUriPermissions(IList<Uri>, Int32)

确定 IPC <em>或 you</em> 的调用进程是否已被授予访问 URI 列表的权限。

(继承自 Context)
CheckCallingPermission(String)

确定你正在处理的 IPC 的调用过程是否已被授予特定权限。

(继承自 ContextWrapper)
CheckCallingUriPermission(Uri, ActivityFlags)

确定是否向调用进程和用户 ID 授予了访问特定 URI 的权限。

(继承自 ContextWrapper)
CheckCallingUriPermissions(IList<Uri>, Int32)

确定是否向调用进程和用户 ID 授予访问 URI 列表的权限。

(继承自 Context)
CheckPermission(String, Int32, Int32)

确定是否允许对系统中运行的特定进程和用户 ID 使用给定权限。

(继承自 ContextWrapper)
CheckSelfPermission(String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
CheckUriPermission(Uri, Int32, Int32, ActivityFlags)

确定是否向特定进程和用户 ID 授予了访问特定 URI 的权限。

(继承自 ContextWrapper)
CheckUriPermission(Uri, String, String, Int32, Int32, ActivityFlags)

检查 URI 和正常权限。

(继承自 ContextWrapper)
CheckUriPermissions(IList<Uri>, Int32, Int32, Int32)

确定是否向特定进程和用户 ID 授予了访问 URI 列表的权限。

(继承自 Context)
ClearWallpaper()
已过时.
(继承自 ContextWrapper)
Clone()

创建并返回此对象的副本。

(继承自 Object)
CreateAttributionContext(String)

返回当前 Context 的新 Context 对象,但返回不同标记的属性。

(继承自 Context)
CreateConfigurationContext(Configuration)

返回当前上下文的新 Context 对象,但其资源已调整为与给定配置匹配。

(继承自 ContextWrapper)
CreateContext(ContextParams)

创建具有特定属性和行为的上下文。

(继承自 Context)
CreateContextForSplit(String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
CreateDeviceContext(Int32)

从当前上下文返回一个新 Context 对象,但具有 由 deviceId给定的设备关联。

(继承自 Context)
CreateDeviceProtectedStorageContext()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
CreateDisplayContext(Display)

返回当前 Context 的新 Context 对象,但其资源已调整为匹配给定 Display 的指标。

(继承自 ContextWrapper)
CreatePackageContext(String, PackageContextFlags)

返回给定应用程序名称的新 Context 对象。

(继承自 ContextWrapper)
CreateWindowContext(Display, Int32, Bundle)

Context为给定 Display上的非android.app.Activity activity窗口创建 。

(继承自 Context)
CreateWindowContext(Int32, Bundle)

为非活动窗口创建上下文。

(继承自 Context)
DatabaseList()

返回一个字符串数组,这些字符串命名与此上下文的应用程序包关联的专用数据库。

(继承自 ContextWrapper)
DeleteDatabase(String)

删除与此上下文的应用程序包关联的现有专用 SQLiteDatabase。

(继承自 ContextWrapper)
DeleteFile(String)

删除与此上下文的应用程序包关联的给定专用文件。

(继承自 ContextWrapper)
DeleteSharedPreferences(String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
Dispose()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
Dispose(Boolean)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
Dump(FileDescriptor, PrintWriter, String[])

将服务的状态打印到给定流中。

EnforceCallingOrSelfPermission(String, String)

如果你和正在处理的 IPC 的调用进程均未被授予特定权限,则 SecurityException引发 。

(继承自 ContextWrapper)
EnforceCallingOrSelfUriPermission(Uri, ActivityFlags, String)

如果 IPC 的调用进程 或你 尚未被授予访问特定 URI 的权限,则引发 SecurityException

(继承自 ContextWrapper)
EnforceCallingPermission(String, String)

如果正在处理的 IPC 的调用过程尚未被授予特定权限,请 SecurityException引发 。

(继承自 ContextWrapper)
EnforceCallingUriPermission(Uri, ActivityFlags, String)

如果尚未向调用进程和用户 ID 授予访问特定 URI 的权限,请引发 SecurityException

(继承自 ContextWrapper)
EnforcePermission(String, Int32, Int32, String)

如果系统中运行的特定进程和用户 ID 不允许给定权限,则 SecurityException引发 。

(继承自 ContextWrapper)
EnforceUriPermission(Uri, Int32, Int32, ActivityFlags, String)

如果尚未向特定进程和用户 ID 授予访问特定 URI 的权限,请引发 SecurityException

(继承自 ContextWrapper)
EnforceUriPermission(Uri, String, String, Int32, Int32, ActivityFlags, String)

强制执行 URI 和普通权限。

(继承自 ContextWrapper)
Equals(Object)

指示某个其他对象是否“等于”此对象。

(继承自 Object)
FileList()

返回一个字符串数组,这些字符串命名与此上下文的应用程序包关联的专用文件。

(继承自 ContextWrapper)
GetColor(Int32)

返回与特定资源 ID 关联的颜色,并针对当前主题设置样式。

(继承自 Context)
GetColorStateList(Int32)

返回与特定资源 ID 关联的颜色状态列表,并为当前主题设置样式。

(继承自 Context)
GetDatabasePath(String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
GetDir(String, FileCreationMode)

检索并根据需要创建一个新目录,应用程序可在其中放置其自己的自定义数据文件。

(继承自 ContextWrapper)
GetDrawable(Int32)

返回与特定资源 ID 关联的可绘制对象,并针对当前主题设置样式。

(继承自 Context)
GetExternalCacheDirs()

返回应用程序可在其拥有的缓存文件的所有外部存储设备上特定于应用程序的目录的绝对路径。

(继承自 ContextWrapper)
GetExternalFilesDir(String)

返回主外部文件系统 (上的目录的绝对路径,该目录位于) 应用程序可以放置其拥有的永久性文件的某个位置 ExternalStorageDirectory

(继承自 ContextWrapper)
GetExternalFilesDirs(String)

返回应用程序可在其拥有的持久文件的所有外部存储设备上特定于应用程序的目录的绝对路径。

(继承自 ContextWrapper)
GetExternalMediaDirs()
已过时.

返回应用程序可以放置媒体文件的所有外部存储设备上特定于应用程序的目录的绝对路径。

(继承自 ContextWrapper)
GetFileStreamPath(String)

返回文件系统上的绝对路径,其中使用 创建 OpenFileOutput(String, FileCreationMode) 的文件是在其中创建的。

(继承自 ContextWrapper)
GetHashCode()

返回对象的哈希代码值。

(继承自 Object)
GetObbDirs()

返回所有外部存储设备上特定于应用程序的目录的绝对路径,其中应用程序的 OBB 文件 ((如果可以找到任何) )。

(继承自 ContextWrapper)
GetSharedPreferences(String, FileCreationMode)

检索并保存首选项文件“name”的内容,返回一个共享首选项,通过该共享首选项可以检索和修改其值。

(继承自 ContextWrapper)
GetString(Int32)

从应用程序包的默认字符串表返回本地化的字符串。

(继承自 Context)
GetString(Int32, Object[])

从应用程序包的默认字符串表返回本地化的字符串。

(继承自 Context)
GetSystemService(Class)

按类将句柄返回到系统级服务。

(继承自 Context)
GetSystemService(String)

按名称将句柄返回到系统级服务。

(继承自 ContextWrapper)
GetSystemServiceName(Class)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
GetText(Int32)

从应用程序包的默认字符串表中返回本地化的、带样式的 CharSequence。

(继承自 Context)
GetTextFormatted(Int32)

从应用程序包的默认字符串表中返回本地化的、带样式的 CharSequence。

(继承自 Context)
GrantUriPermission(String, Uri, ActivityFlags)

向另一个包授予访问特定 URI 的权限,而不管该包是否具有访问 Uri 内容提供程序的常规权限。

(继承自 ContextWrapper)
JavaFinalize()

当垃圾回收确定不再引用对象时,由垃圾回收器对对象调用。

(继承自 Object)
MoveDatabaseFrom(Context, String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
MoveSharedPreferencesFrom(Context, String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
Notify()

唤醒正在等待此对象的监视器的单个线程。

(继承自 Object)
NotifyAll()

唤醒正在等待此对象的监视器的所有线程。

(继承自 Object)
ObtainStyledAttributes(IAttributeSet, Int32[])

检索此上下文主题中的带样式的属性信息。

(继承自 Context)
ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32)

检索此上下文主题中的带样式的属性信息。

(继承自 Context)
ObtainStyledAttributes(Int32, Int32[])

检索此上下文主题中的带样式的属性信息。

(继承自 Context)
ObtainStyledAttributes(Int32[])

检索此上下文主题中的带样式的属性信息。

(继承自 Context)
OnBind(Intent)

将信道返回到服务。

OnConfigurationChanged(Configuration)

在组件运行时设备配置发生更改时由系统调用。

OnCreate()

首次创建服务时由系统调用。

OnDestroy()

由系统调用,以通知服务不再使用且正在删除该服务。

OnLowMemory()

当整个系统的内存不足,并且主动运行的进程应削减其内存使用率时,将调用此名称。

OnRebind(Intent)

当新客户端连接到服务时调用,此前已通知所有客户端都在其 #onUnbind中断开连接。

OnStart(Intent, Int32)
已过时.

此成员已弃用。

OnStartCommand(Intent, StartCommandFlags, Int32)

每次客户端通过调用 android.content.Context#startService显式启动服务时,系统都会调用 ,提供它提供的参数和表示启动请求的唯一整数标记。

OnTaskRemoved(Intent)

如果服务当前正在运行,并且用户删除了来自该服务的应用程序的任务,则调用此方法。

OnTimeout(Int32)

在超时时调用的 ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE回调。

OnTrimMemory(TrimMemory)

当操作系统确定现在是进程从其进程中剪裁不需要的内存的好时机时调用。

OnUnbind(Intent)

当所有客户端都与服务发布的特定接口断开连接时调用。

OpenFileInput(String)

打开与此上下文的应用程序包关联的专用文件以供读取。

(继承自 ContextWrapper)
OpenFileOutput(String, FileCreationMode)

打开与此上下文的应用程序包关联的专用文件进行写入。

(继承自 ContextWrapper)
OpenOrCreateDatabase(String, FileCreationMode, SQLiteDatabase+ICursorFactory)

打开与此上下文的应用程序包关联的新专用 SQLiteDatabase。

(继承自 ContextWrapper)
OpenOrCreateDatabase(String, FileCreationMode, SQLiteDatabase+ICursorFactory, IDatabaseErrorHandler)

打开与此上下文的应用程序包关联的新专用 SQLiteDatabase。

(继承自 ContextWrapper)
PeekWallpaper()
已过时.
(继承自 ContextWrapper)
RegisterComponentCallbacks(IComponentCallbacks)

将新的 ComponentCallbacks 添加到 Context 的基本应用程序,该应用程序将与调用活动的 ComponentCallbacks 方法和其他组件的同时调用。

(继承自 Context)
RegisterDeviceIdChangeListener(IExecutor, IIntConsumer)

将新的设备 ID 更改侦听器添加到 Context,系统更改设备关联时将调用该侦听器。

(继承自 Context)
RegisterReceiver(BroadcastReceiver, IntentFilter)

注册一个 BroadcastReceiver,以在main活动线程中运行。

(继承自 ContextWrapper)
RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags)
已过时.

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
RegisterReceiver(BroadcastReceiver, IntentFilter, ReceiverFlags)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler)

注册以接收意向广播,以在计划程序上下文中运行。

(继承自 ContextWrapper)
RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ActivityFlags)
已过时.

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ReceiverFlags)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
RemoveStickyBroadcast(Intent)
已过时.
(继承自 ContextWrapper)
RemoveStickyBroadcastAsUser(Intent, UserHandle)
已过时.
(继承自 ContextWrapper)
RevokeSelfPermissionOnKill(String)

触发运行时权限的异步吊销。

(继承自 Context)
RevokeSelfPermissionsOnKill(ICollection<String>)

触发对调用包的一个或多个权限的吊销。

(继承自 Context)
RevokeUriPermission(String, Uri, ActivityFlags)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
RevokeUriPermission(Uri, ActivityFlags)

删除之前使用 ) M:Android.Content.Context.GrantUriPermission (System.String、Android.Net.Uri、Android.Net.Uri) 添加的特定内容提供程序 URI 的所有权限。

(继承自 ContextWrapper)
SendBroadcast(Intent)

向所有感兴趣的 BroadcastReceivers 广播给定意向。

(继承自 ContextWrapper)
SendBroadcast(Intent, String)

将给定意向广播给所有感兴趣的 BroadcastReceivers,从而允许强制实施可选的必需权限。

(继承自 ContextWrapper)
SendBroadcast(Intent, String, Bundle)

将给定意向广播给所有感兴趣的 BroadcastReceivers,从而允许强制实施可选的必需权限。

(继承自 Context)
SendBroadcastAsUser(Intent, UserHandle)

SendBroadcast(Intent)允许指定将广播发送到的用户的版本。

(继承自 ContextWrapper)
SendBroadcastAsUser(Intent, UserHandle, String)

SendBroadcast(Intent, String)允许指定将广播发送到的用户的版本。

(继承自 ContextWrapper)
SendBroadcastWithMultiplePermissions(Intent, String[])

将给定意向广播给所有感兴趣的 BroadcastReceivers,从而允许强制实施所需的权限数组。

(继承自 Context)
SendOrderedBroadcast(Intent, Int32, String, String, BroadcastReceiver, Handler, String, Bundle, Bundle)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
SendOrderedBroadcast(Intent, String)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
SendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, Result, String, Bundle)

SendBroadcast(Intent)的版本允许从广播中接收回数据。

(继承自 ContextWrapper)
SendOrderedBroadcast(Intent, String, Bundle)

向所有感兴趣的 BroadcastReceiver 广播给定意向,一次传送一个,以允许更首选的接收器在将广播传送到不太首选的接收器之前使用广播。

(继承自 Context)
SendOrderedBroadcast(Intent, String, Bundle, BroadcastReceiver, Handler, Result, String, Bundle)

#sendBroadcast(Intent)的版本允许从广播中接收回数据。

(继承自 Context)
SendOrderedBroadcast(Intent, String, String, BroadcastReceiver, Handler, Result, String, Bundle)

#sendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, int, String, Bundle)允许你指定应用操作以强制限制广播将发送到哪些接收器的版本。

(继承自 Context)
SendOrderedBroadcastAsUser(Intent, UserHandle, String, BroadcastReceiver, Handler, Result, String, Bundle)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
SendStickyBroadcast(Intent)
已过时.

#sendBroadcast(Intent)执行“粘滞”的 ,这意味着你发送的意向在广播完成后会保留,以便其他人可以通过 的返回值#registerReceiver(BroadcastReceiver, IntentFilter)快速检索该数据。

(继承自 ContextWrapper)
SendStickyBroadcast(Intent, Bundle)

#sendBroadcast(Intent)执行“粘滞”的 ,这意味着你发送的意向在广播完成后会保留,以便其他人可以通过 的返回值#registerReceiver(BroadcastReceiver, IntentFilter)快速检索该数据。

(继承自 Context)
SendStickyBroadcastAsUser(Intent, UserHandle)
已过时.
(继承自 ContextWrapper)
SendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, Result, String, Bundle)
已过时.
(继承自 ContextWrapper)
SendStickyOrderedBroadcastAsUser(Intent, UserHandle, BroadcastReceiver, Handler, Result, String, Bundle)
已过时.
(继承自 ContextWrapper)
SetForeground(Boolean)

此成员已弃用。

SetHandle(IntPtr, JniHandleOwnership)

设置 Handle 属性。

(继承自 Object)
SetTheme(Int32)

设置此上下文的基主题。

(继承自 ContextWrapper)
SetWallpaper(Bitmap)
已过时.
(继承自 ContextWrapper)
SetWallpaper(Stream)
已过时.
(继承自 ContextWrapper)
StartActivities(Intent[])

StartActivities(Intent[], Bundle) 相同,未指定任何选项。

(继承自 ContextWrapper)
StartActivities(Intent[], Bundle)

启动多个新活动。

(继承自 ContextWrapper)
StartActivity(Intent)

StartActivity(Intent, Bundle) 相同,未指定任何选项。

(继承自 ContextWrapper)
StartActivity(Intent, Bundle)

启动新活动。

(继承自 ContextWrapper)
StartActivity(Type)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Context)
StartForeground(Int32, Notification)

如果服务启动 (通过 Context#startService(Intent)) 运行,则还要使此服务在前台运行,从而在处于此状态时向用户提供要显示的持续通知。

StartForeground(Int32, Notification, ForegroundService)

具有其他 foregroundServiceType 参数的 #startForeground(int, Notification) 重载版本。

StartForegroundService(Intent)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
StartInstrumentation(ComponentName, String, Bundle)

开始执行类 Instrumentation

(继承自 ContextWrapper)
StartIntentSender(IntentSender, Intent, ActivityFlags, ActivityFlags, Int32)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 ContextWrapper)
StartIntentSender(IntentSender, Intent, ActivityFlags, ActivityFlags, Int32, Bundle)

例如 StartActivity(Intent, Bundle),但先获取 IntentSender。

(继承自 ContextWrapper)
StartService(Intent)

请求启动给定的应用程序服务。

(继承自 ContextWrapper)
StopForeground(Boolean)

旧版 #stopForeground(int)

StopForeground(StopForegroundFlags)

将此服务从前台状态中删除,以便在需要更多内存时将其终止。

StopSelf()

停止服务(如果以前已启动)。

StopSelf(Int32)

不返回结果的 #stopSelfResult 旧版本。

StopSelfResult(Int32)

如果服务最近启动的时间是 <var>startId</var>,请停止该服务。

StopService(Intent)

请求停止给定的应用程序服务。

(继承自 ContextWrapper)
ToArray<T>()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
ToString()

返回对象的字符串表示形式。

(继承自 Object)
UnbindService(IServiceConnection)

断开与应用程序服务的连接。

(继承自 ContextWrapper)
UnregisterComponentCallbacks(IComponentCallbacks)

ComponentCallbacks删除以前向 注册#registerComponentCallbacks(ComponentCallbacks)的对象。

(继承自 Context)
UnregisterDeviceIdChangeListener(IIntConsumer)

从上下文中删除设备 ID 更改的侦听器。

(继承自 Context)
UnregisterFromRuntime()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
UnregisterReceiver(BroadcastReceiver)

注销以前注册的 BroadcastReceiver。

(继承自 ContextWrapper)
UpdateServiceGroup(IServiceConnection, Int32, Int32)

对于以前与 #bindService 或相关方法绑定的服务,更改系统管理该服务进程的方式(相对于其他进程)。

(继承自 Context)
Wait()

导致当前线程等待,直到它被唤醒,通常是通过 em <通知/em> 或 <em>interrupted</em>。<>

(继承自 Object)
Wait(Int64)

导致当前线程等待,直到它被唤醒,通常是通过 em <通知/em> 或 <em>interrupted</em>,或直到经过一定数量的实时。<>

(继承自 Object)
Wait(Int64, Int32)

导致当前线程等待,直到它被唤醒,通常是通过 em <通知/em> 或 <em>interrupted</em>,或直到经过一定数量的实时。<>

(继承自 Object)

显式接口实现

IJavaPeerable.Disposed()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
IJavaPeerable.DisposeUnlessReferenced()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
IJavaPeerable.Finalized()

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
IJavaPeerable.JniManagedPeerState

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
IJavaPeerable.SetJniIdentityHashCode(Int32)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)
IJavaPeerable.SetPeerReference(JniObjectReference)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

(继承自 Object)

扩展方法

JavaCast<TResult>(IJavaObject)

执行 Android 运行时检查的类型转换。

JavaCast<TResult>(IJavaObject)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

GetJniTypeName(IJavaPeerable)

服务是一个应用程序组件,表示应用程序希望在不与用户交互的情况下执行长时间运行的操作,或者提供供其他应用程序使用的功能。

适用于