Android 常用代码示例---系统服务
2013-09-05 10:18
537 查看
1 | 活动管理器 | |
权限 | <uses-permission android:name="android.permission.GET_TASKS"/> | |
代码 | ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | |
2 | 警报管理器 | |
权限 | ||
代码 | AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); | |
3 | 音频管理器 | |
权限 | ||
代码 | AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); | |
4 | 剪贴板管理器 | |
权限 | ||
代码 | ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); | ; |
5 | 连接管理器 | |
权限 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
代码 | ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
6 | 输入法管理器 | |
权限 | ||
代码 | InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | |
7 | 键盘管理器 | |
权限 | ||
代码 | KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); | |
8 | 布局解压器管理器 | |
权限 | ||
代码 | LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
9 | 位置管理器 | |
权限 | ||
代码 | LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); | |
10 | 通知管理器 | |
权限 | ||
代码 | NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | |
11 | 电源管理器 | |
权限 | <uses-permission android:name="android.permission.DEVICE_POWER"/> | |
代码 | PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); | |
12 | 搜索管理器 | |
权限 | ||
代码 | SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); | |
13 | 传感器管理器 | |
权限 | ||
代码 | SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); | |
14 | 电话管理器 | |
权限 | <uses-permission android:name="android.permission.READ_PHONE_STATE"/> | |
代码 | TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); | |
15 | 振动器 | |
权限 | <uses-permission android:name="android.permission.VIBRATE"/> | |
代码 | Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); | |
16 | 墙纸 | |
权限 | <uses-permission android:name="android.permission.SET_WALLPAPER"/> | |
代码 | WallpaperService wallpaperService = (WallpaperService) getSystemService(Context.WALLPAPER_SERVICE); | |
17 | Wi-Fi管理器 | |
权限 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | |
代码 | WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); | |
18 | 窗口管理器 | |
权限 | ||
代码 | WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); |
相关文章推荐
- android 20个常用的系统调用代码片段
- Android常用代码之普通及系统权限静默安装APK
- android系统中常用的弹出提示框使用代码
- Android——常用的系统服务
- Android开发——Intent调用系统组件21个常用小示例
- Android常用的几个系统参数相关代码片段
- Android常用系统服务 学习笔记
- Android 常用系统服务
- Android的Context && 安卓常用系统服务(当前运行包名/当前网络状态和开关网络/音频服务/马达服务) (转)
- 【Android】16.0 第16章 自定义服务和系统服务—本章示例主界面
- Android常用代码之普通及系统权限静默安装APK
- 我不要紧的编码组两人,至少两年的dotnet网咯服务开发经验,熟悉数据库orm, 系统管理人员:熟悉各linux发行版的系统管理和安全管理,linux常用数据库的配置与运维等,有代码托管服务管理经验优
- Android --- 常用的系统服务(一)
- Android常用系统服务
- Android的Context && 安卓常用系统服务(当前运行包名/当前网络状态和开关网络/音频服务/马达服务)
- Android原生代码添加系统服务
- Android 物理游戏之重力系统开发示例代码
- Android 常用的系统服务简介
- Android中常用的系统服务
- Android 常用系统服务 学习总结