Search in sources :

Example 1 with LocationProvider

use of com.litingzhe.justandroid.ui.mapView.AMapUtils.LocationProvider in project JustAndroid by chinaltz.

the class MapActivity method didLocation.

@AfterPermissionGranted(REQUEST_LOCATION_PERM)
public void didLocation() {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        locationProvider = new LocationProvider(this);
        // 获取locationservice实例,建议应用中只初始化1个location实例,然后使用,可以参考其他示例的activity,都是通过此种方式获取locationservice实例的
        locationProvider.registerListener(locationListener);
        // 注册监听
        locationProvider.setLocationOption(locationProvider.getDefaultOption());
        locationProvider.start();
    } else {
        // Ask for one permission
        EasyPermissions.requestPermissions(this, "需要使用位置信息权限", REQUEST_LOCATION_PERM, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }
}
Also used : LocationProvider(com.litingzhe.justandroid.ui.mapView.AMapUtils.LocationProvider) AfterPermissionGranted(pub.devrel.easypermissions.AfterPermissionGranted)

Aggregations

LocationProvider (com.litingzhe.justandroid.ui.mapView.AMapUtils.LocationProvider)1 AfterPermissionGranted (pub.devrel.easypermissions.AfterPermissionGranted)1