1.获取当前地理位置:Android中提供了一个LocationManager的类,用于管理地理位置。不能通过构造函数获取该类的实例,而是通过Context的getSystemService():LocationManager lm = (LocationManager) getSystemServ...
分类:
移动开发 时间:
2015-07-19 13:08:34
阅读次数:
316
PowerManager pm=(PowerManager) getSystemService(Context.POWER_SERVICE); //获取电源管理器对象 PowerManager.WakeLock wl = pm.newWakeLock(P...
分类:
移动开发 时间:
2015-07-18 22:39:07
阅读次数:
227
Android开发之获取布局填充器的三种方式第一种 : LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.item_listview, nul...
分类:
移动开发 时间:
2015-07-17 18:56:53
阅读次数:
137
LayoutInflater作用是将layout的xml布局文件实例化为View类对象。获取LayoutInflater的方法有如下三种:?LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_...
分类:
其他好文 时间:
2015-07-15 16:35:16
阅读次数:
173
一丶传感器//拿到传感器管理器SensorManagersm=(SensorManager)getSystemService(SENSOR_SERVICE);//拿到手机里支持的所有的传感器List<Sensor>sensors=sm.getSensorList(Sensor.TYPE_ALL);for(inti=0;i<sensors.size();i++){Sensorsensor=sensors.get(i);System.out...
分类:
移动开发 时间:
2015-07-13 18:54:40
阅读次数:
165
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
RunningTaskInfo info = manager.getRunningTasks(1).get(0);
String shortClassName = info...
分类:
其他好文 时间:
2015-07-13 12:11:27
阅读次数:
92
android的后台存在很多service,它们在系统启动的时候被SystemServer开启,来为系统的正常运行做支撑。Activity中要调用这些service就得使用getSystemService方法,这也是Activity很重要的一个API。根据传入的Name取得对应的Object,然后转换成相应的服务对象。
传入的Name
返回的对象
说明...
分类:
其他好文 时间:
2015-07-10 13:35:23
阅读次数:
119
1.NotificationManager ma=(NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);2. NotificationCompat.Builder b=new Notificati.....
分类:
其他好文 时间:
2015-07-08 18:37:25
阅读次数:
110
private Boolean isOnline() { ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = ...
分类:
移动开发 时间:
2015-07-03 15:18:41
阅读次数:
152
一,获取Android设备的所有存储设备,这里边肯定有一个能用的
StorageManager sm = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
String[] paths = (String[]) sm.getClass().getMethod("getVolumePaths", null).in...
分类:
移动开发 时间:
2015-06-30 18:25:22
阅读次数:
127