获取用户当前位置:
1、在manifest文件中声明相应的权限;-----GPS定位:android.premission.ACCESS.FINE.LOCATION (较常用,精确)
-----NETWORK定位:android.premission.ACCESS.COARSE.LOCATION
2、获取LocationManger对象;-----LocationManger locationmanger = (LocationManger)MainActivity.getSystemService(Context.LOCATION_SERVICE);
3、选择LocationProvide; -----locationmanger.requestlocationUpdates(LocationManger.GPS_PROVIDE,0,0,new LocationListener)
//第一个参数:选择的provide,第二个参数:获取位置的时间间隔,第三个参数:位移,第四个参数绑定的locationlistener对象;
4、绑定LocationListener对象;-----private class locationlistener implements LocationListener{四个方法}
//1、onLocationChanged 2、onProvideDisabled 3、onProvideEnabled 4、onStatusChanged