对于Android CDMA手机获取当前位置,其实有更便利的办法,就是哄骗CdmaCellLocation.getBaseStationLatitude(),然则getBaseStationLatitude()获取的是int值的纬度,在android doc里也没有具体的论说。国外的论坛也有人说getBaseStationLatitude()返回的是垃圾信息,昨天google到一个泡菜国兄弟的帖子才找到getBaseStationLatitude()获取的是int值与真正经纬度之间的关系。
也就是CDMA层3和谈的定义:
/**
* Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
* It is represented in units of 0.25 seconds and ranges -1296000
* to 1296000, both values inclusive (corresponding to a range of -90
* to +90 degrees). Integer.MAX_VALUE is considered invalid value.
*/
/**
* Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.
* It is represented in units of 0.25 seconds and ranges -2592000
* to 2592000, both values inclusive (corresponding to a range of -180
* to +180 degrees). Integer.MAX_VALUE is considered invalid value.
*/
是以只要将getBaseStationLatitude()做如下处理惩罚即可:
double lat = (double)myCDMACellLoc.getBaseStationLatitude() /14400;
double lon = (double)myCDMACellLoc.getBaseStationLongitude() /14400;
/14400即 *90/1296000
如许题目就解决了!!!
关键代码:
- telephonyManager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
- myCDMACellLoc = (CdmaCellLocation)telephonyManager.getCellLocation();
- double lat = (double)myCDMACellLoc.getBaseStationLatitude() /14400;
- double lon = (double)myCDMACellLoc.getBaseStationLongitude() /14400;