Search in sources :

Example 11 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project SmartMesh_Android by SmartMeshFoundation.

the class LoadDataService method initLocation.

/**
 *-----------------------------------------------Directory to upload related to an end---------------------------------------------------------------*
 */
/**
 *-----------------------------------------Positioning related to start------------------------------------------
 */
/**
 * Initialize the positioning
 */
private void initLocation() {
    // Initialize the client
    locationClient = new AMapLocationClient(this.getApplicationContext());
    // Setting up the positioning parameters
    locationClient.setLocationOption(getDefaultOption());
    // Establishment of listening
    locationClient.setLocationListener(locationListener);
    // Start position
    locationClient.startLocation();
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient)

Example 12 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project Ency by xiarunhao123.

the class MainActivity method initLocation.

/**
 * 定位初始化
 */
private void initLocation() {
    // 初始化定位
    mLocationClient = new AMapLocationClient(mContext);
    // 设置定位回调监听
    mLocationClient.setLocationListener(this);
    mLocationOption = new AMapLocationClientOption();
    // 设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式
    mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
    // 设置是否返回地址信息(默认返回地址信息)
    mLocationOption.setNeedAddress(true);
    // 设置是否只定位一次,默认为false
    mLocationOption.setOnceLocation(false);
    // 设置是否强制刷新WIFI,默认为强制刷新
    mLocationOption.setWifiActiveScan(true);
    // 设置是否允许模拟位置,默认为false,不允许模拟位置
    mLocationOption.setMockEnable(false);
    // 设置定位间隔 单位毫秒
    mLocationOption.setInterval(100 * 1000 * 60 * 60);
    // 给定位客户端对象设置定位参数
    mLocationClient.setLocationOption(mLocationOption);
    // 关闭缓存机制
    mLocationOption.setLocationCacheEnable(false);
    // 启动定位
    mLocationClient.startLocation();
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient) AMapLocationClientOption(com.amap.api.location.AMapLocationClientOption)

Example 13 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project KL2 by jweihao.

the class GaoDeActivity method initLocation.

/**
 * 初始化定位
 */
private void initLocation() {
    if (null == locationClient) {
        // 初始化client
        locationClient = new AMapLocationClient(this.getApplicationContext());
        // 设置定位参数
        locationClient.setLocationOption(getDefaultOption());
        // 设置定位监听
        locationClient.setLocationListener(mAMapLocationListener);
    }
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient)

Example 14 with AMapLocationClient

use of com.amap.api.location.AMapLocationClient in project LivingInCampus by DulCoder.

the class MainActivity method initLocation.

/**
 * 初始化定位
 */
private void initLocation() {
    // 初始化定位
    mLocationClient = new AMapLocationClient(getApplicationContext());
    // 设置定位回调监听
    mLocationClient.setLocationListener(mLocationListener);
    // 初始化AMapLocationClientOption对象
    mLocationOption = new AMapLocationClientOption();
    // 设置定位模式为AMapLocationMode.Battery_Saving,低功耗模式。
    // mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Battery_Saving);
    // 设置退出时是否杀死service
    mLocationOption.setKillProcess(true);
    // 设置是否返回地址信息(默认返回地址信息)
    mLocationOption.setNeedAddress(true);
    // 获取是否单次定位
    mLocationOption.setOnceLocation(true);
    // 给定位客户端对象设置定位参数
    mLocationClient.setLocationOption(mLocationOption);
    // 启动定位
    mLocationClient.startLocation();
}
Also used : AMapLocationClient(com.amap.api.location.AMapLocationClient) AMapLocationClientOption(com.amap.api.location.AMapLocationClientOption)

Example 15 with AMapLocationClient

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

the class CitySelectorActivity method initGaodeLocation.

/**
 * 初始化高德地图定位
 */
private void initGaodeLocation() {
    gaodeClient = new AMapLocationClient(this);
    AMapLocationClientOption option = new AMapLocationClientOption();
    option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
    // 设置只定位一次
    option.setOnceLocation(true);
    // 设置返回地址信息
    option.setNeedAddress(true);
    // 定位超时
    option.setHttpTimeOut(20000);
    // option.setInterval(20000);// 设置定位间隔,默认为2000ms,最低1000ms。
    gaodeClient.setLocationListener(new AMapLocationListener() {

        @Override
        public void onLocationChanged(AMapLocation aMapLocation) {
            if (aMapLocation != null) {
                if (aMapLocation.getErrorCode() == 0) {
                    String city = aMapLocation.getCity();
                    String district = aMapLocation.getDistrict();
                    mCityAdapter.updateLocateState(LocateState.SUCCESS, city);
                    CLogUtil.d("高德city: " + city);
                    CLogUtil.d("高德district: " + district);
                } else {
                    // 定位失败
                    mCityAdapter.updateLocateState(LocateState.FAILED, null);
                    CLogUtil.e("高德Error, ErrCode:" + aMapLocation.getErrorCode() + ", errInfo:" + aMapLocation.getErrorInfo());
                }
            }
        }
    });
    gaodeClient.setLocationOption(option);
    // gaodeClient.startLocation();
    checkLocationPermission();
}
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)

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