Android源碼個個擊破之LocationManager-創(chuàng)新互聯(lián)

GPS NMEA-0183標(biāo)準(zhǔn)數(shù)據(jù)介紹

創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)與策劃設(shè)計,宣威網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:宣威等地區(qū)。宣威做網(wǎng)站價格咨詢:18980820575

https://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生成實例的位置

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這個類添加進(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

點到直線的距離計算公式: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元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

文章標(biāo)題:Android源碼個個擊破之LocationManager-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://muchs.cn/article24/dhggce.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、網(wǎng)站設(shè)計公司網(wǎng)站收錄、手機(jī)網(wǎng)站建設(shè)、搜索引擎優(yōu)化、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)