本文整理汇总了Java中com.amap.api.location.AMapLocation.getErrorCode方法的典型用法代码示例。如果您正苦于以下问题:Java AMapLocation.getErrorCode方法的具体用法?Java AMapLocation.getErrorCode怎么用?Java AMapLocation.getErrorCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amap.api.location.AMapLocation
的用法示例。
在下文中一共展示了AMapLocation.getErrorCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (mListener != null && aMapLocation != null) {
if (aMapLocation != null && aMapLocation.getErrorCode() == 0) {
mAMapLocation = aMapLocation;
mlocationClient.stopLocation();
mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点
lp = new LatLonPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude());
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lp.getLatitude(), lp.getLongitude()), 17));
doSearchQuery(aMapLocation.getPoiName().trim(), aMapLocation.getCityCode(), false);
} else {
String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
ToastUtils.showToast(this, errText);
}
}
}
示例2: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
String lat = aMapLocation.getLatitude() + "";
String lng = aMapLocation.getLongitude() + "";
sharedPref.edit().putString("Latitude", lat).apply();
sharedPref.edit().putString("Longitude", lng).apply();
} else {
Toast.makeText(
MainActivity.this,
aMapLocation.getErrorInfo(),
Toast.LENGTH_LONG
).show();
}
}
}
示例3: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 实现定位
* @param amapLocation
*/
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation != null
&&amapLocation.getErrorCode() == 0) {
if(isFirstTime){//只要第一次的数据,当然,也可以在这里关闭定位
// mlocationClient.stopLocation();//停止定位
mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
lvHolder.title = "[位置]";
lvHolder.address = amapLocation.getProvider()+amapLocation.getCity()+amapLocation.getStreet()+amapLocation.getStreetNum();
lvHolder.lp = new LatLonPoint(amapLocation.getLatitude(),amapLocation.getLongitude());
mEndMarker.setPosition(new LatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
data.add(0,lvHolder);
doSearchQuery();
}
} else {
String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
Log.e("AmapErr",errText);
}
}
}
示例4: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位地点
* @param amapLocation
*/
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null&&amapLocation != null) {
EventBus.getDefault().post(amapLocation);
if (amapLocation != null
&&amapLocation.getErrorCode() == 0) {
if(startList.size()==0)
startList.add(new NaviLatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
if(!calculateSuccess){
mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
}
} else {
String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
Log.e("AmapErr",errText);
}
}
}
示例5: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation loc) {
if (null != loc && loc.getErrorCode() == 0) {
//解析定位结果
mLongitude = loc.getLongitude();
mLatitude = loc.getLatitude();
city = loc.getCity();
country = loc.getCountry();
Log.i("XLight", String.format("long:%s,latitude:%s,city:%s,country:%s", mLongitude, mLatitude, city, country));
//请求天气信息
updateLocationInfo();
locationClient.stopLocation();
} else {
// 定位失败,显示提示
Log.e("XLight", "location Error, ErrCode:"
+ loc.getErrorCode() + ", errInfo:"
+ loc.getErrorInfo());
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtil.showToast(getActivity(), R.string.open_gps);
}
});
}
}
示例6: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
mCity = aMapLocation.getCity();
mSwipeRefreshLayout.setEnabled(true);
mSwipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
mSwipeRefreshLayout.setRefreshing(true);
}
});
getWeatherData(mCity);
}
//定位失败,通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息
else {
SnackBarUtil.showSnackBar(aMapLocation.getErrorInfo(), mSwipeRefreshLayout, getActivity());
}
}
}
示例7: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//可在其中解析amapLocation获取相应内容
updateUserLocation(amapLocation.getCity());
initCardWeather(amapLocation.getCity());
mLocationClient.stopLocation();//停止定位后,本地定位服务并不会被销毁
} else {
//定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
Log.e("AmapError", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
} else {
}
}
示例8: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (mListener != null && aMapLocation != null) {
if (aMapLocation != null
&& aMapLocation.getErrorCode() == 0) {
LatLng location = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
if (!mFirstFix) {
mFirstFix = true;
addCircle(location, aMapLocation.getAccuracy());//添加定位精度圆
addMarker(location);//添加定位图标
mSensorHelper.setCurrentMarker(mLocMarker);//定位图标旋转
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 18));
} else {
mCircle.setCenter(location);
mCircle.setRadius(aMapLocation.getAccuracy());
mLocMarker.setPosition(location);
mAMap.moveCamera(CameraUpdateFactory.changeLatLng(location));
}
} else {
String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
Log.e("AmapErr", errText);
}
}
}
示例9: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
//可在其中解析amapLocation获取相应内容。
double locationType = amapLocation.getLocationType();//获取当前定位结果来源,如网络定位结果,详见定位类型表
double latitude = amapLocation.getLatitude();//获取纬度
double longitude = amapLocation.getLongitude();//获取纬度
L.i("location", "locationType:" + locationType + ",latitude:" + latitude + ",longitude:" + longitude);
LatLng latLng = new LatLng(latitude, longitude);
getAddressByLatlng(latLng);
} else {
//定位失败时,可通过ErrCode(错误码)信息来确定失败的原因,errInfo是错误信息,详见错误码表。
L.i("location", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
}
}
示例10: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位成功后回调函数
*/
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation != null && amapLocation.getErrorCode() == 0) {
tvResult.setVisibility(View.GONE);
mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
} else {
String errText = "定位失败," + amapLocation.getErrorCode() + ": "
+ amapLocation.getErrorInfo();
Log.e("AmapErr", errText);
tvResult.setVisibility(View.VISIBLE);
tvResult.setText(errText);
}
}
}
示例11: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (amapLocation != null) {
if (amapLocation.getErrorCode() == AMapLocation.LOCATION_SUCCESS) {
Logger.e("经度 = " + amapLocation.getLongitude() + "\n" + "纬度 = " + amapLocation.getLatitude());
if (!isWriteData) {
writeData(amapLocation);
}
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
Logger.e("AmapError", "location Error, ErrCode:"
+ amapLocation.getErrorCode() + ", errInfo:"
+ amapLocation.getErrorInfo());
}
RxBusManager.post(EventConstant.KEY_LOCATION, getLocationBean(amapLocation));
}
}
示例12: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation != null && amapLocation.getErrorCode() == 0) {
mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
LatLng mylocation = new LatLng(amapLocation.getLatitude(),
amapLocation.getLongitude());
mAMap.moveCamera(CameraUpdateFactory.changeLatLng(mylocation));
if (btn.isChecked()) {
record.addpoint(amapLocation);
mPolyoptions.add(mylocation);
redrawline();
}
} else {
String errText = "定位失败," + amapLocation.getErrorCode() + ": "
+ amapLocation.getErrorInfo();
Log.e("AmapErr", errText);
}
}
}
示例13: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
//高德定位回调
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
updateLocation(aMapLocation);
if (BuildConfig.DEBUG)
MapUtil.showLocationInfor(aMapLocation);
} else {
//显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。
if (BuildConfig.DEBUG) {
LogMgr.e("AmapError", "location Error, ErrCode:"
+ aMapLocation.getErrorCode() + ", errInfo:"
+ aMapLocation.getErrorInfo());
}
}
}
}
示例14: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
/**
* 定位监听回掉
*/
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
mCity = amapLocation.getCity();
mCityTextView.setText(mCity);
mPresenter.searchWeatherRecord(getContext(), amapLocation.getCity());
mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
} else {
String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
Log.e("AmapErr", errText);
//mLocationErrText.setVisibility(View.VISIBLE);
//mLocationErrText.setText(errText);
}
}
}
示例15: onLocationChanged
import com.amap.api.location.AMapLocation; //导入方法依赖的package包/类
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation.getErrorCode() == 0) {
// mCity = amapLocation.getCity();
// mCityTextView.setText(mCity);
//
// mPresenter.searchWeatherRecord(getContext(), amapLocation.getCity());
mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
} else {
String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
Log.e("AmapErr", errText);
//mLocationErrText.setVisibility(View.VISIBLE);
//mLocationErrText.setText(errText);
}
}
}