如何在android中离线获取经纬度? [英] How to get latitude and longitude offline in android ?
本文介绍了如何在android中离线获取经纬度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取当前位置(纬度和经度),当 WiFi 和Gps 已关闭.可以从移动 sim 网络获取纬度和经度.我在谷歌上搜索了更多,但我没有得到满意的答案.
I want to get current location (latitude & longitude) , when WiFi & Gps is off .It is possible to get latitude and longitude from mobile sim network. I searched more on google but i did not get satisfies answers.
推荐答案
试试这个
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if(location==null){
location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
这篇关于如何在android中离线获取经纬度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文