//第一步先获取LocationManager的对象
LocationManager GpsManager = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
//通过LocationManager的对象来获取到Location的信息。
Location location = GpsManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
//Location中经常用到的有以下几种:/* location.getAccuracy(); 精度 location.getAltitude(); 高度 : 海拔 location.getBearing(); 导向 location.getSpeed(); 速度 location.getLatitude(); 纬度 location.getLongitude(); 经度 location.getTime(); UTC时间 以毫秒计*/
注:需要添加使用权限的哦
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号