高德地图所使用的权限
写完后发现蓝点没出来,看遍文档也没发现原因,发现要显示定位蓝点,需要 ACCESS_FINE_LOCATION 权限
另外,还需要判断gps有没有打开,没有的话需要引导用户打开gps
//判断gps是否打开
fun isOpenGps():Boolean = (context.getSystemService(Context.LOCATION_SERVICE) as
LocationManager)
.run {
isProviderEnabled(LocationManager.GPS_PROVIDER)
}
//跳转到打开gps设置页面
fun openGPSSetting(activity:Activity,requestCode:Int) = activity.startActivityForResult(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),requestCode)
fun openGPSSetting(fragment:Fragment,requestCode:Int) = fragment.startActivityForResult(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),requestCode)