本文整理匯總了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);
}
}
}