代码拉取完成,页面将自动刷新
#简介
初学轻敲,高抬贵手
#定位 Demo
采用Gradle构建
##SDK Version
locSDK_6.13.jar
baidumapapi_v3_6_0.jar
##Usage ###1.初始化
private MainLocationManager mainLocationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
mainLocationManager = MainLocationManager.getInstance();
//...
}
@Override
protected void onDestroy() {
super.onDestroy();
mainLocationManager.stopBaiduLocation();
}
@Override
protected void onResume() {
super.onResume();
mainLocationManager.registerListener(mainLocationListener);
}
@Override
protected void onPause() {
super.onPause();
mainLocationManager.unregisterListener(mainLocationListener);
}
private MainLocationListener mainLocationListener = new MainLocationListener() {
@Override
public void onLocationChanged(MyLocation location) {//定位成功
if (location == null)
return ;
//...
}
@Override
public void onLocationFail(String provider, String message) { }//定位失败
@Override
public void onStatusChanged(String provider, int status, Bundle extras) { }//暂可无视
@Override
public void onProviderEnabled(String provider) { }//暂可无视
@Override
public void onProviderDisabled(String provider) { }//暂可无视
};
###2.调用定位方法
isNeedAddress 是否需要地址信息
scanSpan 获取位置信息时间间隔(>=1000ms)
注:需要地址信息,没有网络情况下将导致定位失败
获取一次
mainLocationManager.getBaiduLocationOnce(isNeedAddress);
持续获取
mainLocationManager.getBaiduLocationAuto(scanSpan);//默认不需要地址信息
mainLocationManager.getBaiduLocationAuto(scanSpan, isNeedAddress);
##Screenshots
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型