- <SPAN style="FONT-FAMILY: Tahoma, Helvetica, SimSun, sans-serif, Hei; WHITE-SPACE: normal"></SPAN>
目前获取经纬度一共有两种方法:
一是通过谷歌的地图API来获取经纬度,一般获取的精确度比较的大,详细请参考文章:
http://www.shouyanwang.org/thread-32-1-1.html
还剩下的一种就是借助移动的基站定位来获取经纬度:
移动基站的定位必须借助存储卡,目前已经测试的,中国电信和中国移动的卡都支持,联通的还没有测试,那么如何获取借助基站获取经纬度呢?
借助TelephonyManager和GsmCellLocation就可以实现了,非常的简单,获取的值为整型的值,因此是没有通过谷歌地图API的精确的。
- privateint cellId = 0;
- privateint lac = 0;
- privatevoid getCellLac(){
- TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
- String OperatorName = tm.getNetworkOperatorName();
- if(OperatorName.equals("中国联通") || OperatorName.equals("中国移动")||OperatorName.equals("中国电信")){
- GsmCellLocation location = (GsmCellLocation)tm.getCellLocation();
- cellId = location.getCid();
- lac = location.getLac();
- }
- }
private int cellId = 0; private int lac = 0; private void getCellLac(){ TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); String OperatorName = tm.getNetworkOperatorName(); if(OperatorName.equals("中国联通") || OperatorName.equals("中国移动")||OperatorName.equals("中国电信")){ GsmCellLocation location = (GsmCellLocation)tm.getCellLocation(); cellId = location.getCid(); lac = location.getLac(); } }