當前位置: 首頁>>代碼示例>>Java>>正文


Java AMapLocation.getErrorCode方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:PoiAroundSearchActivity.java

示例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();
        }
    }
}
 
開發者ID:SEALiu,項目名稱:Calendouer,代碼行數:20,代碼來源:MainActivity.java

示例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);
            }
        }
    }
 
開發者ID:Vicent9920,項目名稱:MyMap,代碼行數:29,代碼來源:PiclocationActivity.java

示例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);
        }
    }
}
 
開發者ID:Vicent9920,項目名稱:MyMap,代碼行數:23,代碼來源:NavigationActivity.java

示例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);
            }
        });
    }
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:26,代碼來源:GlanceMainFragment.java

示例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());
        }
    }
}
 
開發者ID:xiarunhao123,項目名稱:PureNews,代碼行數:21,代碼來源:WeatherFragment.java

示例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 {

    }
}
 
開發者ID:monsterLin,項目名稱:Pigeon,代碼行數:19,代碼來源:WeatherActivity.java

示例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);
        }
    }
}
 
開發者ID:InnoFang,項目名稱:FamilyBond,代碼行數:26,代碼來源:MapActivity.java

示例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());
        }
    }
}
 
開發者ID:InnoFang,項目名稱:FamilyBond,代碼行數:20,代碼來源:HandleMessageService.java

示例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);
		}
	}
}
 
開發者ID:amapapi,項目名稱:Android_Location_Demo,代碼行數:19,代碼來源:GeoFence_District_Activity.java

示例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));
    }
}
 
開發者ID:pinguo-sunjianfei,項目名稱:Android-Application-ZJB,代碼行數:18,代碼來源:LocationManager.java

示例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);
		}
	}
}
 
開發者ID:amapapi,項目名稱:RecordPath3D,代碼行數:21,代碼來源:MainActivity.java

示例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());
            }
        }
    }
}
 
開發者ID:joy-inc,項目名稱:joy-app,代碼行數:20,代碼來源:MapActivity.java

示例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);
        }
    }
}
 
開發者ID:Alex-ZHOU,項目名稱:VMAndroid,代碼行數:22,代碼來源:RecordFragment.java

示例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);
            }
        }
    }
 
開發者ID:Alex-ZHOU,項目名稱:VMAndroid,代碼行數:19,代碼來源:RecordDBActivity.java


注:本文中的com.amap.api.location.AMapLocation.getErrorCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。