通过Activity类的getSystemService方法可以获得指定的系统服务。
getSystemService方法只有一个String类型的参数,表示系统服务的ID,这个ID在整个Android系统中是唯一的。
Android SDK在android.content.Context类中定义了这些ID。如下:
Constants | ||
AccessibilityManager | ACCESSIBILITY_SERVICE | 通过已注册的事件监听器将UI事件反馈给用户。 主要是一些View获得点击、焦点、文字改变等事件的分发管理,对整个系统的调试、问题定位等,也需要最这个服务仔细过目一下。 |
AccountManager | ACCOUNT_SERVICE | 在你选择的时间接收 Intents |
ActivityManager | ACTIVITY_SERVICE | Activity服务 |
AlarmManager | ALARM_SERVICE | 闹钟服务 |
AppOpsManager | APP_OPS_SERVICE | Use with getSystemService(String) to retrieve a AppOpsManager for tracking application operations on the device. 在设备操作跟踪应用 |
AudioManager | AUDIO_SERVICE | 音频服务。管理音量,响铃模式和音频路由 |
BluetoothAdapter | BLUETOOTH_SERVICE | 蓝牙服务 |
CaptioningManager | CAPTIONING_SERVICE | Use with getSystemService(String) to retrieve a CaptioningManager for obtaining captioning properties and listening for changes in captioning preferences. |
ClipboardManager | CLIPBOARD_SERVICE | 剪切板服务 |
ConnectivityManager | CONNECTIVITY_SERVICE | 网络连接服务。可供其他应用查询,当网络状态变化时,也可广播改变。 |
ConsumerIrManager | CONSUMER_IR_SERVICE | 红外信号服务。操作发射红外信号的装置 |
DevicePolicyManager | DEVICE_POLICY_SERVICE | 设备监听服务 |
DisplayManager | DISPLAY_SERVICE | Use with getSystemService(String) to retrieve a DisplayManager for interacting with display devices. 获取 DisplayManager 以和显示设备交互。 |
DownloadManager | DOWNLOAD_SERVICE | 下载服务。HTTP下载请求 |
DropBoxManager | DROPBOX_SERVICE | 获取 DropBoxManager 实例以记录诊断日志。 |
InputMethodManager | INPUT_METHOD_SERVICE | 输入法的管理服务程序,包括何时使能输入法,切换输入法等等。 |
InputManager | INPUT_SERVICE | 获取 InputManager 以和输入设备交互。 |
NotificationManager | KEYGUARD_SERVICE | 获取 NotificationManager 以控制键盘锁 |
LayoutInflater | LAYOUT_INFLATER_SERVICE | Use with getSystemService(String) to retrieve a LayoutInflater for inflating layout resources in this context. |
LocationManager | LOCATION_SERVICE | GPS定位服务等 |
MediaRouter | MEDIA_ROUTER_SERVICE | Use with getSystemService(String) to retrieve a MediaRouter for controlling and managing routing of media. |
NfcManager | NFC_SERVICE | Use with getSystemService(String) to retrieve a NfcManager for using NFC. NFC |
NotificationManager | NOTIFICATION_SERVICE | 负责管理和通知后台事件的发生等,这个和statusbar胶黏在一起,一般会在statusbar上添加响应图标。用户可以通过这知道系统后台发生了什么事情。 |
NsdManager | NSD_SERVICE | Use with getSystemService(String) to retrieve a NsdManager for handling management of network service discovery |
PowerManager | POWER_SERVICE | 电源服务 |
PrintManager | PRINT_SERVICE | 打印服务。打印和管理打印机和打印任务 |
SearchManager | SEARCH_SERVICE | 搜索服务 |
SensorManager | SENSOR_SERVICE | 传感器服务 |
StorageManager | STORAGE_SERVICE | 系统存储服务 |
TelephonyManager | TELEPHONY_SERVICE | 电话服务 |
TextServicesManager | TEXT_SERVICES_MANAGER_SERVICE | Use with getSystemService(String) to retrieve a TextServicesManager for accessing text services. |
UiModeManager | UI_MODE_SERVICE | Use with getSystemService(String) to retrieve a UiModeManager for controlling UI modes. |
UsbManager | USB_SERVICE | Use with getSystemService(String) to retrieve a UsbManager for access to USB devices (as a USB host) and for controlling this device's behavior as a USB device. |
UserManager | USER_SERVICE | 用户管理服务。在支持多用户设备上管理用户 |
Vibrator | VIBRATOR_SERVICE | 振动器服务 |
com.android.server. WallpaperService | WALLPAPER_SERVICE | 壁纸服务 |
WifiP2pManager | WIFI_P2P_SERVICE | WIFI-P2P连接服务 |
WifiManager | WIFI_SERVICE | WIFI服务 |
WindowManager | WINDOW_SERVICE | 系统窗口服务 |