在初始化自己位置的时候请求定位权限:
Constants.ACCESS_FINE_LOCATION_COMMANDS_REQUEST_CODE是自定义的常量值==0x01

                    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)                            != PackageManager.PERMISSION_GRANTED) {                        //申请WRITE_EXTERNAL_STORAGE权限                        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, Constants.ACCESS_FINE_LOCATION_COMMANDS_REQUEST_CODE);                    } else {                     /**                     * 初始化用户位置                     */                        setMyLoctionPicture();                    }
 /**     * 初始化用户位置     */    public void setMyLoctionPicture(){       LogUtils.d(TAG,"setMyLocationPicture() is running");        if(aMap==null){            aMap=mapview.getMap();        }        MyLocationStyle locationStyle = new MyLocationStyle();        locationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.mipmap.location_marker));        locationStyle.strokeColor(Color.BLACK);        locationStyle.radiusFillColor(Color.argb(100, 0, 0, 100));        locationStyle.strokeWidth(1.0f);        aMap.setMyLocationStyle(locationStyle);        aMap.setLocationSource(this);        UiSettings uiSettings = aMap.getUiSettings();        uiSettings .setMyLocationButtonEnabled(true);        aMap.setMyLocationEnabled(true);        aMap.setInfoWindowAdapter(this);        aMap.setOnMarkerClickListener(this);    }

这样是确保在Android高版本时定位权限不会被屏蔽;导致定位和导航用不了情况。

更多相关文章

  1. 2014.01.10 ——— android listview 记录和恢复位置
  2. android检查权限是否获取
  3. Android百度地图默认位置中心点设置
  4. Android 权限清单
  5. rem初始化设置
  6. Android用属性动画拖动view到任意位置
  7. Android Kotlin 动态申请权限
  8. android 开发技巧(12)--更改 Toast 显示位置的技巧
  9. android 权限列表

随机推荐

  1. Android(安卓)SDK等下载说明
  2. Android(安卓)Spinner
  3. android状态栏一体化(沉浸式状态栏)
  4. android工程导出成为jar包。
  5. Android(安卓)JNI详述(二)
  6. Java,Android(安卓)Integer和byte的相互转
  7. EditText无法获取焦点(android:descendant
  8. Android监听Home、电源键
  9. 用ndk-build 工具手动生成编译android原
  10. android 输入键盘遮挡页面的问题