Cześć, mam taki problem w jednej aktywności pobieram lokalizacje gps, i chcialbym w drugiej aktywności po nacisnieciu przycisku uruchomić tą metode, ale wszystkie próby kończą się wyłaczeniem aplikacji
GetGPS gps = new GetGPS(this);
gps.updategps();
public void updategps() {
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.
return;
}
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, timeupdate, 10, locationListenerGPS);
}