分类:C#、Android、VS2015;

创建日期:2016-03-01

一、简介

实际上,在Android.Content.Context类中,Android已经提供了多种类型的系统服务,这些服务都以静态的形式通过Android.Content.ContextWrapper类提供的GetSystemService()方法让开发人员调用。

在Activity及其子类中,可直接调用GetSystemService方法。例如:

public class MainActivity : Activity{    LocationManager locMgr;    ……    protected override void OnResume()    {        locMgr = GetSystemService(Context.LocationService) as LocationManager;        ……..    }    ……}

二、系统服务类型

Context类提供的系统服务很多,下面仅列出一些常用的服务。这些服务都是以常量字符串的形式定义在Context类中的,键入Context和“.”即可可看到这些服务。

AudioService:音频服务

BatteryService:电池服务

BluetoothService:蓝牙服务

CameraService:相机服务

ConnectivityService:网络连接管理服务

LocationService:位置服务,控制位置等设备的更新

WifiService:Wi-Fi连接管理

VibratorService:设备震动服务,用于访问支持振动的硬件

AlarmService:在指定的时间接受Intent报警

其他系统服务

Context提供的其他系统服务还有:

AccessibilityService
AccountService
ActivityService
AppOpsService
AppwidgetService
CaptioningService
CarrierConfigService
ClipboardService
ConsumerIrService
DevicePolicyService
DisplayService
DownloadService
DropboxService
FingerprintService
InputMethodService:输入法管理
InputService
JobSchedulerService
KeyguardService
LauncherAppsService
LayoutInflaterService
MediaProjectionService
MediaRouterService
MediaSessionService
MidiService
NetworkStatsService
NfcService
NotificationService:后台事件通知
NsdService
PowerService:电源管理
PrintService
RestrictionsService
SearchService
SensorService
StorageService
TelecomService
TelephonyService
TelephonySubscriptionService
TextServicesManagerService
TvInputService
UiModeService
UsageStatsService
UsbService
UserService
WallpaperService
WifiP2pService
WindowService--最顶层的窗口服务

更多相关文章

  1. 在Windows系统中使用NDK编译Android二进制文件并运行
  2. Android 日志系统logcat内核代码分析
  3. Android应用程序获取系统权限
  4. android如何调用显示和隐藏系统默认的输入法
  5. 配置新的product(译)——android编译系统
  6. Android系统自带样式(android:theme)(stephen830的博客)
  7. 【Android 系统开发】 编译 Android文件系统 u-boot 内核 并烧写

随机推荐

  1. MySQL5.7.33安装过程图文详解
  2. Mysql索引选择以及优化详解
  3. MySQL中explain语句的基本使用教程
  4. MySQL mysqladmin客户端的使用简介
  5. MySQL MGR搭建过程中常遇见的问题及解决
  6. MySQL 权限控制细节分析
  7. MySQL 权限控制详解
  8. MySQL 利用frm文件和ibd文件恢复表数据
  9. MySQL使用Xtrabackup备份流程详解
  10. MySQL GTID全面总结