您的位置:首页 > 移动开发 > Android开发

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);
17Wi-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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: