GPS NMEA-0183標(biāo)準(zhǔn)數(shù)據(jù)介紹
創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),宣威網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:宣威等地區(qū)。宣威做網(wǎng)站價(jià)格咨詢:18980820575https://www.cnblogs.com/rechen/p/5135409.html? (可以準(zhǔn)確判斷是否在定位)
源碼分析:
?https://www.ibm.com/developerworks/cn/opensource/os-cn-android-location/
1.?源碼所在的目錄
2.?
http://ju.outofmemory.cn/entry/111182
3.?
4.?LocationManager生成實(shí)例的位置
5.?frameworks/base/core/java/android/app/ContextImpl.java
registerService(LOCATION_SERVICE,?new?ServiceFetcher()?{
????public?Object?createService(ContextImpl?ctx)?{
????????IBinder?b?=?ServiceManager.getService(LOCATION_SERVICE);
????????return?new?LocationManager(ctx,?ILocationManager.Stub.asInterface(b));
????}
});
而ServiceManager里的的"LOCATION_SERVICE"又是從com.android.server.SystemServer這個(gè)類添加進(jìn)去的
if?(!disableLocation)?{
????traceBeginAndSlog("StartLocationManagerService");
????try?{
????????location?=?new?LocationManagerService(context);
????????ServiceManager.addService(Context.LOCATION_SERVICE,?location);
????}?catch?(Throwable?e)?{
????????reportWtf("starting?Location?Manager",?e);
????}
????Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
????traceBeginAndSlog("StartCountryDetectorService");
????try?{
????????countryDetector?=?new?CountryDetectorService(context);
????????ServiceManager.addService(Context.COUNTRY_DETECTOR,?countryDetector);
????}?catch?(Throwable?e)?{
????????reportWtf("starting?Country?Detector",?e);
????}
????Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
}
LocationManagerService的reportLocation方法觸發(fā)了應(yīng)用上層onLocationFound的回調(diào)
@Override
public?void?reportLocation(Location?location,?boolean?passive)?{
????checkCallerIsProvider();
????if?(!location.isComplete())?{
????????Log.w(TAG,?"Dropping?incomplete?location:?"?+?location);
????????return;
????}
????mLocationHandler.removeMessages(MSG_LOCATION_CHANGED,?location);
????Message?m?=?Message.obtain(mLocationHandler,?MSG_LOCATION_CHANGED,?location);
????m.arg1?=?(passive???1?:?0);
????mLocationHandler.sendMessageAtFrontOfQueue(m);
}
順藤摸瓜,最終找到
public?boolean?callLocationChangedLocked(Location?location)?{
????if?(mListener?!=?null)?{
????????try?{
????????????synchronized?(this)?{
????????????????//?synchronize?to?ensure?incrementPendingBroadcastsLocked()
????????????????//?is?called?before?decrementPendingBroadcasts()
????????????????mListener.onLocationChanged(new?Location(location));
????????????????//?call?this?after?broadcasting?so?we?do?not?increment
????????????????//?if?we?throw?an?exeption.
????????????????incrementPendingBroadcastsLocked();
????????????}
????????}?catch?(RemoteException?e)?{
????????????return?false;
????????}
????}?else?{
那么LocationManagerService的reportLocation方法又是怎么被觸發(fā)的呢?
?
1.?ILocationManager.aidl
2.?frameworks/base/location/java/android/location/ILocationManager.aidl
3.?
4.?
GPS定位漂移產(chǎn)生的原因:https://baike.1688.com/doc/view-d41865087.html
GPS的NEMA協(xié)議解析:https://blog.csdn.net/adazone/article/details/45152291
點(diǎn)到直線的距離計(jì)算公式:https://blog.csdn.net/bagboy_taobao_com/article/details/6291462
經(jīng)緯度求坐標(biāo)方位角:?https://blog.csdn.net/u010175314/article/details/76093934
NMEA編碼:https://baike.baidu.com/item/NMEA/9812575?fr=aladdin
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。