getSystemService使用汇总

getSystemService

使用案例

WifiManager wifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);	
WifiManager wifiManager = (WifiManager)getSystemService("wifi");

部分Manager

Manager 常量 String
AccessibilityManager ACCESSIBILITY_SERVICE accessibility
AccountManager ACCOUNT_SERVICE account
ActivityManager ACTIVITY_SERVICE activity
AlarmManager ALARM_SERVICE alarm
AppWidgetManager APPWIDGET_SERVICE appwidget
AppOpsManager APP_OPS_SERVICE appops
AudioManager AUDIO_SERVICE audio
BatteryManager BATTERY_SERVICE batterymanager
BluetoothManager BLUETOOTH_SERVICE bluetooth
CameraManager CAMERA_SERVICE camera
CaptioningManager CAPTIONING_SERVICE captioning
CarrierConfigManager CARRIER_CONFIG_SERVICE carrier_config
ClipboardManager CLIPBOARD_SERVICE clipboard
CompanionDeviceManager COMPANION_DEVICE_SERVICE companiondevice
ConnectivityManager CONNECTIVITY_SERVICE connectivity
ConsumerIrManager CONSUMER_IR_SERVICE consumer_ir
DevicePolicyManager DEVICE_POLICY_SERVICE device_policy
DisplayManager DISPLAY_SERVICE display
DownloadManager DOWNLOAD_SERVICE download
DropBoxManager DROPBOX_SERVICE dropbox
FingerprintManager FINGERPRINT_SERVICE fingerprint
HardwarePropertiesManager HARDWARE_PROPERTIES_SERVICE hardware_properties
InputMethodManager INPUT_METHOD_SERVICE input_method
InputManager INPUT_SERVICE input
JobScheduler JOB_SCHEDULER_SERVICE jobscheduler
KeyguardManager KEYGUARD_SERVICE keyguard
LauncherApps LAUNCHER_APPS_SERVICE launcherapps
LayoutInflater LAYOUT_INFLATER_SERVICE layout_inflater
LocationManager LOCATION_SERVICE location
MediaProjectionManager MEDIA_PROJECTION_SERVICE media_projection
MediaRouter MEDIA_ROUTER_SERVICE media_router
MediaSessionManager MEDIA_SESSION_SERVICE media_session
MidiManager MIDI_SERVICE midi
NetworkStatsManager NETWORK_STATS_SERVICE netstats
NfcManager NFC_SERVICE nfc
NotificationManager NOTIFICATION_SERVICE notification
NsdManager NSD_SERVICE servicediscovery
PowerManager POWER_SERVICE power
PrintManager PRINT_SERVICE print
RestrictionsManager RESTRICTIONS_SERVICE restrictions
SearchManager SEARCH_SERVICE search
SensorManager SENSOR_SERVICE sensor
ShortcutManager SHORTCUT_SERVICE shortcut
StorageManager STORAGE_SERVICE storage
StorageStatsManager STORAGE_STATS_SERVICE storagestats
SystemHealthManager SYSTEM_HEALTH_SERVICE systemhealth
TelecomManager TELECOM_SERVICE telecom
TelephonyManager TELEPHONY_SERVICE phone
TelephonyManager TELEPHONY_SUBSCRIPTION_SERVICE telephony_subscription_service
TextClassificationManager TEXT_CLASSIFICATION_SERVICE textclassification
TextServicesManager TEXT_SERVICES_MANAGER_SERVICE textservices
TvInputManager TV_INPUT_SERVICE tv_input
UiModeManager UI_MODE_SERVICE uimode
UsageStatsManager USAGE_STATS_SERVICE usagestats
UsbManager USB_SERVICE usb
UserManager USER_SERVICE user
Vibrator VIBRATOR_SERVICE vibrator
WallpaperManager WALLPAPER_SERVICE wallpaper
WifiAwareManager WIFI_AWARE_SERVICE wifiaware
WifiP2pManager WIFI_P2P_SERVICE wifip2p
WifiManager WIFI_SERVICE wifi
WindowManager WINDOW_SERVICE window

TelephonyManager

作用

​ 管理手机通话状态

​ 获取电话信息(设备信息,sim卡信息以及网络信息)

​ 监听电话状态(呼叫状态服务状态,信号强度状态等)

​ 调用电话拨号器拨打电话

WindowManager

int h = windowManager.getDefauwltDisplay().getHeight();
int w = windowManager.getDefaultDisplay().getWidth();

你可能感兴趣的:(Android,Android基础)