Search in sources :

Example 6 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project ride-read-android by Ride-Read.

the class MapFragment method activate.

@Override
public void activate(OnLocationChangedListener onLocationChangedListener) {
    mListener = onLocationChangedListener;
    parentActivity = (MainActivity) getActivity();
    if (parentActivity.mLocationOption == null) {
        // 初始化AMapLocationClientOption对象
        parentActivity.mLocationOption = new AMapLocationClientOption();
    }
    if (aMapLocationClient == null) {
        aMapLocationClient = new AMapLocationClient(getActivity().getApplicationContext());
    }
    setLocationMode(parentActivity.mLocationOption);
    initLocation();
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient) AMapLocationClientOption(com.amap.api.location.AMapLocationClientOption)

Example 7 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project CustomViews by AndroidStudy233.

the class MainActivity method initLocation.

private void initLocation() {
    /*
            注意这只是个测试,没有做6.0系统的兼容.6.0以下是没问题的
         */
    mLocationClient = new AMapLocationClient(this);
    AMapLocationClientOption option = new AMapLocationClientOption();
    option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
    // 设置只定位一次
    option.setOnceLocation(true);
    // 设置返回地址信息
    option.setNeedAddress(true);
    // option.setInterval(20000);// 设置定位间隔,默认为2000ms,最低1000ms。
    mLocationClient.setLocationListener(new AMapLocationListener() {

        @Override
        public void onLocationChanged(AMapLocation aMapLocation) {
            if (aMapLocation != null) {
                if (aMapLocation.getErrorCode() == 0) {
                    String city = aMapLocation.getCity();
                    String district = aMapLocation.getDistrict();
                    MyLogUtil.debug("高德city: " + city);
                    MyLogUtil.debug("高德district: " + district);
                } else {
                    // 定位失败
                    MyLogUtil.error("高德Error, ErrCode:" + aMapLocation.getErrorCode() + ", errInfo:" + aMapLocation.getErrorInfo());
                }
            }
        }
    });
    mLocationClient.setLocationOption(option);
    mLocationClient.startLocation();
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient) AMapLocation(com.amap.api.location.AMapLocation) AMapLocationClientOption(com.amap.api.location.AMapLocationClientOption) AMapLocationListener(com.amap.api.location.AMapLocationListener)

Example 8 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project YourEyes by SevenLJY.

the class LocationUtils method initLocation.

//初始化定位
private static void initLocation(Context context) {
    locationClient = new AMapLocationClient(context);
    locationClient.setLocationOption(getDefaultOption());
    //设置定位监听
    locationClient.setLocationListener(locationListener);
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient)

Example 9 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project YourEyes by SevenLJY.

the class MyLocationActivity method initLocation.

private void initLocation() {
    mLocationClient = new AMapLocationClient(this.getApplicationContext());
    //设置定位参数
    mLocationClient.setLocationOption(getDefaultOption());
    //设置定位监听
    mLocationClient.setLocationListener(locationListener);
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient)

Example 10 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project YourEyes by SevenLJY.

the class LocationService method initLocation.

private void initLocation() {
    mLocationClient = new AMapLocationClient(this.getApplicationContext());
    //设置定位参数
    mLocationClient.setLocationOption(getDefaultOption());
    //设置定位监听
    mLocationClient.setLocationListener(locationListener);
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient)

Aggregations

AMapLocationClient (com.amap.api.location.AMapLocationClient)17 AMapLocationClientOption (com.amap.api.location.AMapLocationClientOption)10 AMapLocation (com.amap.api.location.AMapLocation)4 AMapLocationListener (com.amap.api.location.AMapLocationListener)4 Message (android.os.Message)1