Hi, ist sicher ganz simpel. Aber mit welcher Methode frage ich ab, ob das GPS an oder aus geschaltet ist.
Irgendwie suche ich schon wieder viel zu lange.
Zur Zeit erkenne ich das nur, wenn meine location ein "null" zurückgibt.
PS: Es geht nicht um die Berechtigung.
Irgendwie suche ich schon wieder viel zu lange.
Zur Zeit erkenne ich das nur, wenn meine location ein "null" zurückgibt.
Java:
@SuppressLint("MissingPermission")
private void updateLocation() {
FusedLocationProviderClient fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
fusedLocationProviderClient.getLastLocation().addOnSuccessListener(this::onLocationReceived);
}
private void onLocationReceived(Location location) {
if (location == null) {
textView.setText("Bitte GPS einschalten");
return;
}
double latitude = location.getLatitude();
double longitude = location.getLongitude();
textView.setText("" + latitude + " | " + longitude);
}
PS: Es geht nicht um die Berechtigung.