GPS NMEA-0183标准数据介绍
创新互联是一家专注于成都网站设计、成都网站建设与策划设计,宣威网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:宣威等地区。宣威做网站价格咨询:18980820575https://www.cnblogs.com/rechen/p/5135409.html (可以准确判断是否在定位)
源码分析:
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这个类添加进去的
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方法触发了应用上层onLocationFound的回调
@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方法又是怎么被触发的呢?
1. ILocationManager.aidl
2. frameworks/base/location/java/android/location/ILocationManager.aidl
3.
4.
GPS定位漂移产生的原因:https://baike.1688.com/doc/view-d41865087.html
GPS的NEMA协议解析:https://blog.csdn.net/adazone/article/details/45152291
点到直线的距离计算公式:https://blog.csdn.net/bagboy_taobao_com/article/details/6291462
经纬度求坐标方位角: https://blog.csdn.net/u010175314/article/details/76093934
NMEA编码:https://baike.baidu.com/item/NMEA/9812575?fr=aladdin
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章标题:Android源码个个击破之LocationManager-创新互联
网站地址:https://www.cdcxhl.com/article24/dhggce.html
成都网站建设公司_创新互联,为您提供标签优化、网站设计公司、网站收录、手机网站建设、搜索引擎优化、ChatGPT
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联