1、获得当前应用包名
public static String getRunningActivityName(Context context) {
ActivityManager activityManager=(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
//完整类名
String runni...
分类:
移动开发 时间:
2015-06-26 13:03:00
阅读次数:
348
http://blog.sina.com.cn/s/blog_71d1e4fc0100o8qr.htmlhttp://blog.csdn.net/bianhaohui/article/details/6220135 android的后台运行在很多service,它们在系统启动时被SystemSer....
分类:
移动开发 时间:
2015-06-25 11:53:58
阅读次数:
139
GPS英文是Global Positioning System 全球定位系统的简称。
Android为GPS功能支持专门提供了一个LocationManager,位置管理器。所有GPS定位相关的服务、对象都将由该对象产生。
获取LocationManager实例:
LocationManager lm = (LocationManager)getSystemService (Contex...
分类:
移动开发 时间:
2015-06-24 18:53:30
阅读次数:
203
Android系统提供了对传感器的支持。
开发应用传感器很简单,只需要为指定监听器注册一个监听器即可。
步骤:
1.调用Context的getSystemService(Context.SENSOR_SERVICE)方法 获取SensorManager对象,SensorManager对象代表系统的传感器管理服务
2.调用SensorManager的getDefaultSensor(in...
分类:
移动开发 时间:
2015-06-23 20:06:46
阅读次数:
145
getSystemService是Android很重要的一个API,它是Activity的一个方法,根据传入的NAME来取得对应的Object,然后转换成相应的服务对象。下面介绍系统相应的服务:传入的Name返回的对象说明WINDOW_SERVICEWindowManager管理打开的窗口程序LAY...
分类:
移动开发 时间:
2015-06-23 19:32:17
阅读次数:
171
总共有两类方法:一、代码直接判定二、接收广播现在先说第一类方法(代码直接判定):1、通过PowerManager的isScreenOn方法,代码如下:PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SER...
分类:
移动开发 时间:
2015-06-20 20:53:33
阅读次数:
152
Vibrator vibrator= (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000); //这里的参数是指 震动多少毫秒
vibrator.cancel(); //取消震动
别忘记添加震动权限...
分类:
移动开发 时间:
2015-06-17 09:31:26
阅读次数:
138
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);String imsi = mTelephonyMgr.getSubscriberId();String i...
分类:
移动开发 时间:
2015-06-16 20:59:18
阅读次数:
253
IMEI号,IESI号,手机型号:[java]view plaincopyprint?privatevoidgetInfo(){TelephonyManagermTm=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);Stringimei=m...
分类:
移动开发 时间:
2015-06-16 20:49:31
阅读次数:
179
1、方法一(如果输入法在窗口上已经显示,则隐藏,反之则显示)1 InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);2 imm.toggleSoftInput(0, ...
分类:
移动开发 时间:
2015-06-14 22:47:47
阅读次数:
171