getSystemService是Android很重要的一个API,它是Activity的一个方法,根据传入的NAME来取得对应的Object,然后转换成相应的服务对象。以下介绍系统相应的服务。
传入的Name |
返回的对象 |
说明 |
WINDOW_SERVICE |
WindowManager |
管理打开的窗口程序 |
LAYOUT_INFLATER_SERVICE |
LayoutInflater |
取得xml里定义的view |
ACTIVITY_SERVICE |
ActivityManager |
管理应用程序的系统状态 |
POWER_SERVICE
|
PowerManger |
电源的服务 |
ALARM_SERVICE |
AlarmManager |
闹钟的服务 |
NOTIFICATION_SERVICE
|
NotificationManager |
状态栏的服务 |
KEYGUARD_SERVICE |
KeyguardManager |
键盘锁的服务 |
LOCATION_SERVICE |
LocationManager |
位置的服务,如GPS |
SEARCH_SERVICE |
SearchManager |
搜索的服务 |
VEBRATOR_SERVICE |
Vebrator |
手机震动的服务 |
CONNECTIVITY_SERVICE |
Connectivity |
网络连接的服务 |
WIFI_SERVICE |
WifiManager |
Wi-Fi服务 |
TELEPHONY_SERVICE |
TeleponyManager |
电话服务 |
分享到:
相关推荐
这个文档对android中的getSystemService有详细的讲解
Android的getSystemService函数学习总结
本文实例分析了Android getSystemService用法。分享给大家供大家参考,具体如下: 1. 说明 android的后台运行在很多service,它们在系统启动时被SystemServer开启,支持系统的正常工作,比如MountService监听是否有...
Android长按复制文本,长按粘贴文本。Android长按复制文本,长按粘贴文本。
核心代码:Imei = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceId();1.加入权限在manifest.xml文件中要添加 <uses android:name=”android.permission.READ_PHONE_STATE”>2.代码 代码如下:...
本文实例讲述了Android编程实现禁止StatusBar下拉的方法。分享给大家供大家参考,具体如下: Android中有许多隐藏的Service,StatusBarManager就是其中一个,在Context.java中可以看到: /** * Use with {@link #...
Android 提供了现成 android.os.PowerManager 类 , 类中 提供newWakeLock(int flags, String tag)方法 来取得 应用层的锁, 此函数的定义 frameworks/base/core/java/android/os/PowerManager.java 应用程序 在...
pm = (PowerManager) getSystemService(Context.POWER_SERVICE); //保持cpu一直运行,不管屏幕是否黑屏 wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CPUKeepRunning"); wakeLock.acquire(); }...
在Android里,程序内存被分为2部分:native和dalvik,dalvik就是我们普通的Java使用内存,分析堆栈的时候使用的内存。...ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVIC
本文实例讲述了Android编程获取Wifi名称(SSID)的方法。分享给大家供大家参考,具体如下: 可以使用WifiManager和WifiInfo来获取当前Wifi连接信息 WifiManager wifiManager = (WifiManager) getSystemService(WIFI_...
lm =(LocationManager) this.getSystemService(Context`.LOCATION_SERVICE); // ``` **2.一般使用LocationManager的getLastKnownLocation(LocationManager.GPS_PROVIDER);方法获取Location对象** ``` String ...
ActivityManager mActivityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); Method method = Class.forName("android.app.ActivityManager").getMethod...
android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F0EFF5" > android:id="@+id/sayit_rl_tab" android:layout_width="fill_parent" android:layout_...
.getSystemService(Context.LOCATION_SERVICE); if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) { Toast.makeText(this, "GPS模块正常", Toast.LENGTH_SHORT).show(); ...
TelephonyManager类的对象可以通过Context.getSystemService(Context.TELEPHONY_SERVICE)方法来获得,需要注意的是有些通讯信息的获取对应用程序的权限有一定的限制,在开发的时候需要为其添加相应的权限。
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(m_receiverView(接受软键盘输入的视图(View)),InputMethodManager.SHOW_FORCED(提供当前操作的...
信号强度的监听是Android手机十分常见的一个重要功能。今天本文就以实例展示Android实现信号强度监听的方法。...Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); Tel.listen(M
lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE); statusListener = new GpsStatus.Listener() //GPS状态监听器 { @Override public void onGpsStatusChanged(int event) ...
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); tv = (TextView) findViewById(R.id.tv); localPowerManager = (PowerManager) getSystemService(POWER_SERVICE); // 获取PowerManager....