public Object getSystemService (String name)
Since: API Level 1
Return the handle to a system-level service by name. The class of the returned object varies by the requested name. Currently available names are:
WINDOW_SERVICE ("window")
The top-level window manager in which you can place custom windows. The returned object is a WindowManager.
LAYOUT_INFLATER_SERVICE ("layout_inflater")
A LayoutInflater for inflating layout resources in this context.
ACTIVITY_SERVICE ("activity")
A ActivityManager for interacting with the global activity state of the system.
POWER_SERVICE ("power")
A PowerManager for controlling power management.
ALARM_SERVICE ("alarm")
A AlarmManager for receiving intents at the time of your choosing.
NOTIFICATION_SERVICE ("notification")
A NotificationManager for informing the user of background events.
KEYGUARD_SERVICE ("keyguard")
A KeyguardManager for controlling keyguard.
LOCATION_SERVICE ("location")
A LocationManager for controlling location (e.g., GPS) updates.
SEARCH_SERVICE ("search")
A SearchManager for handling search.
VIBRATOR_SERVICE ("vibrator")
A Vibrator for interacting with the vibrator hardware.
CONNECTIVITY_SERVICE ("connection")
A ConnectivityManager for handling management of network connections.
WIFI_SERVICE ("wifi")
A WifiManager for management of Wi-Fi connectivity.
INPUT_METHOD_SERVICE ("input_method")
An InputMethodManager for management of input methods.
UI_MODE_SERVICE ("uimode")
An UiModeManager for controlling UI modes.
DOWNLOAD_SERVICE ("download")
A DownloadManager for requesting HTTP downloads
分享到:
相关推荐
Android的getSystemService函数学习总结
本文实例分析了Android getSystemService用法。分享给大家供大家参考,具体如下: 1. 说明 android的后台运行在很多service,它们在系统启动时被SystemServer开启...以android系统支持sensor(传感器)实例来说明框架层的
虽然我不是Framework工程师, 但是了解Android系统还是很有好处的. 如何获取系统服务 我们获取系统服务都是在context中,getSystemService获取到的. 那么我们看一下getSystemService发生了哪些些事情. ...
而本文将介绍android设备中已启动的服务,并判断某一服务是启动 1.根据ACTIVITY_SERVICE获取系统服务 activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); 2.获取系统中正在运行的服务 ...
利用系统服务做到闹钟的功能 private Intent intent; private PendingIntent pendingIntent; private Calendar calendar; private AlarmManager alarmManager; @Override protected void onCreate(Bundle ...
手机锁屏后,Android系统为了省电以及减少CPU消耗,在一段时间后会将手机进入休眠状态。此时的服务以及线程等都会停止。 最近就这个问题,阅读了很多代码以及官方文档,下面就说下最近都尝试过的方式,可能其中有些...
1.调用显示系统默认的输入法 方法一、 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(m_receiverView(接受软键盘输入的视图(View)),...
Android 原生系统一般默认16M,但是国内手机一般都是特殊定制的,都有修改系统的内存大小,所有有时候,要查看具体应用系统分配的内存大小,还是需要实际去测试的, 测试方法如下: 方式一: ActivityManager ...
PackagesInfo pi = new PackagesInfo(this); ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); //获取正在运行的应用 获得当前系统所有应用
Android 提供了现成 android.os.PowerManager 类 , 类中 提供newWakeLock(int flags, String tag)方法 来取得 应用层的锁, 此函数的定义 frameworks/base/core/java/android/os/PowerManager.java 应用程序 在...
Android 手机系统中的重力传感器+源码,作者信息:Himi,重力传感器也称为加速度传感器,源代码编译环境需要SDK 1.5(api 3)支持。 此传感器不仅对玩家反转手机的动作可以检测到,而且会根据反转手机的程度,得到...
//获取系统服务 lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE); statusListener = new GpsStatus.Listener() //GPS状态监听器 { @Override public void ...
当我们要使用android的系统服务时,一般都是使用Context.getSystemService方法。例如我们要获取AudioManager,我们可以: AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 获取的服务...
通过程序获取android系统手机的铃声和音量。同样,设置铃声和音量的方法也很简单! 设置音量的方法也很简单,AudioManager提供了方法: public voidsetStreamVolume(intstreamType,intindex,intflags) 其中...
一个调用系统getSystemService ALARM SERVICE 的闹钟例子 代码简单易懂
判断网络是否可用: 注意!是判断网络是否可用,但网络可用不代表一定能上外网的! public static boolean ... .getApplicationContext().getSystemService( Context.CONNECTIVITY_SERVICE); if (m
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!pm.isIgnoringBatteryOptimizations(getPackageName())){ Intent ...
在Android系统中可以通过AlarmManager类实现闹钟,AlarmManager类是专门用来设定在某个指定的时间去完成指定的事件。AlarmManager提供了访问系统警报的服务,只要在程序中设置了警报服务,AlarmManager就会通过...
实现系统重启的APK需要system的权限,在AndroidManifest.xml中增加android:sharedUserId=”android.uid.system”,再修改签名即可; 具体方法参考: 点击打开链接 1、使用PowerManager来实现:代码: 代码如下:...