android - Kotlin NullPointerException 问题
问题描述
我正在使用 Google Map 制作应用程序,但我遇到了权限问题。有人可以帮助我吗?虽然 Android 10 没有问题,但 Android 9 有这个问题。这些 106-115 行的代码
if (ContextCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
requestPermissions(arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION),1)
}else{
locationManager!!.requestLocationUpdates(LocationManager.GPS_PROVIDER,2,2f,locationListener)
mMap.clear()
var lastLocation = locationManager!!.getLastKnownLocation(LocationManager.GPS_PROVIDER)
var lastUserLocation = LatLng(lastLocation!!.latitude,lastLocation!!.longitude)
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(lastUserLocation,17f))
}
解决方案
推荐阅读
- sql - 将值插入到只有 1 列的表中
- google-sheets-api - Google.Apis.Requests.RequestError 未找到请求的实体。[404]
- python - 将列表的每个元素与没有循环的列表连接起来
- amazon-web-services - AttributeDefinitions 和 KeySchemas 中的属性集必须在 Resources/DynamoDB/Properties 匹配
- frequency - 频率计数法
- html - 如何使用 thymeleaf 在 Spring Boot 中加载图像?
- laravel - 使用前缀时在laravel中找不到url
- javascript - d3 树状图:替换根保留老树
- javascript - 如何将终端输出和输入转换为电子应用 gui
- visual-studio - ReSharper/Rider 是否支持未定义的符号补全?