`
bywyu
  • 浏览: 19640 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

getSystemService

阅读更多

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函数学习总结

    Android的getSystemService函数学习总结

    Android getSystemService用法实例总结

    本文实例分析了Android getSystemService用法。分享给大家供大家参考,具体如下: 1. 说明 android的后台运行在很多service,它们在系统启动时被SystemServer开启,支持系统的正常工作,比如MountService监听是否有...

    Android powermanger wakelock

    通过 Context.getSystemService().方法获取PowerManager实例。 然后通过PowerManager的newWakeLock ((int flags, String tag)来生成WakeLock实例。int Flags指示要获取哪种WakeLock,不同的Lock对cpu 、屏幕、键盘灯...

    Android长按复制文本

    Android长按复制文本,长按粘贴文本。Android长按复制文本,长按粘贴文本。

    Android_开发技巧杂集_网络_半透明_异步线程

    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(  3. Context.CONNECTIVITY_SERVICE);  4. NetworkInfo info = cm.getActiveNetworkInfo();  5. return (info != null && info....

    Beginning iOS 6 Development Exploring the iOS SDK SourceCode

    Beginning iOS 6 Development Exploring the iOS SDK SourceCode

    Android获取当前应用分配的最大内存和目前使用内存的方法

    在Android里,程序内存被分为2部分:native和dalvik,dalvik就是我们普通的Java使用内存,分析堆栈的时候使用的内存。...ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVIC

    Android 指定手机号的手机震动模式自定义实例.rar

     TelephonyManager tm=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);//创建TelephonyManager对象  tm.listen(mPSL, PhoneStateListener.LISTEN_CALL_STATE);//添加监听器

    Android之TelephonyManager类的方法详解

    TelephonyManager类的对象可以通过Context.getSystemService(Context.TELEPHONY_SERVICE)方法来获得,需要注意的是有些通讯信息的获取对应用程序的权限有一定的限制,在开发的时候需要为其添加相应的权限。

    安卓单任务多线程任意断点下载【源码】.rar

     LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);  3.使用inflate(int resource, ViewGroup root)方法生成新的View  4.调用当前页面中某个容器的addView,将新创建的...

    KillRunApkApplication.rar

    ActivityManager mActivityManager = (ActivityManager) myContext.getSystemService(Context.ACTIVITY_SERVICE); Method method = Class.forName("android.app.ActivityManager").getMethod("forceStopPackage", ...

    Android监听摇动手机代码

    代码扒自Facebook的开源项目React Native 摇晃手机打开开发者选项的代码 ...使用方法: ShakeDetector shakeDetector = new ShakeDetector... shakeDetector.start((SensorManager) getSystemService(SENSOR_SERVICE));

    GPRS网络开关

    final ConnectivityManager conman = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final Class conmanClass = Class.forName(conman.getClass().getName()); final Field ...

    Android Proximity Alert 手机接近进警告或提示功能一例.rar

     LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);  //定义接近区域的大致经度、纬度  double longitude = 113.39;  double latitude = 23.13;  //定义接近区域的半径(5...

    BroadcastDemo

    .getSystemService(Context.ALARM_SERVICE); // Action指向我们的BoxinReceiver Intent intent = new Intent(this, BoxinReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(MainActivity....

    Android GPS

    .getSystemService(Context.LOCATION_SERVICE); if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) { Toast.makeText(this, "GPS模块正常", Toast.LENGTH_SHORT).show(); ...

    Android通过距离传感器控制屏幕熄灭案例代码

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); tv = (TextView) findViewById(R.id.tv); localPowerManager = (PowerManager) getSystemService(POWER_SERVICE); // 获取PowerManager....

    Android代码-EnFloatingView

    mWindowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams() layoutParams.type = WindowManager....

Global site tag (gtag.js) - Google Analytics