Не хочет выводить координаты, в чем может быть проблема ?
class MyProfile : AppCompatActivity() {
private lateinit var ttextVie: TextView
private lateinit var locationManager: LocationManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_my_profile)
ttextVie = findViewById(R.id.textView)
locationManager = getSystemService(LOCATION_SERVICE) as LocationManager
}
override fun onResume() {
super.onResume()
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_FINE_LOCATION
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(
this,
Manifest.permission.ACCESS_COARSE_LOCATION
) != PackageManager.PERMISSION_GRANTED
) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
ttextVie.text = "нет разрешений"
return
} else {
locationManager?.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
1L,
1f,
locationListener
)
}
}
override fun onPause() {
super.onPause()
locationManager.removeUpdates(locationListener)
}
private val locationListener: LocationListener = object : LocationListener {
override fun onLocationChanged(location: Location) {
ttextVie.text = ("" + location.longitude + ":" + location.latitude)
}
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {}
override fun onProviderEnabled(provider: String) {}
override fun onProviderDisabled(provider: String) {}
}
}
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
implementation 'com.google.android.gms:play-services-location:17.0.0'
Разрешения на местоположения в настройках включил