android开发肿么获得手机的gps

Android手机

1个回答

写回答

库洛米@

2026-01-24 04:05

+ 关注

//第一步先获取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时间 以毫秒计*/

注:需要添加使用权限的哦

举报有用(0分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号