I make this query, even before it worked and I think (at least I think) have not deleted anything but I stop working.
Can not find the location of the device to store latitude and longitude. The permissions in the Manifesto are, I'm telling you yesterday it worked for me and suddenly I stop doing it
ActivityCompat.requestPermissions(UltimoPaso.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 120);
if (ActivityCompat.checkSelfPermission(UltimoPaso.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
{
Log.e("Permisos: ", "No se han definido los permisos necesarios");
}else
{
/*Se asigna a la clase LocationManager el servicio a nivel de sistema a partir del nombre.*/
locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
loc = locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}
if (loc != null) {
Log.e("Latitud: ", (String.valueOf(loc.getLatitude())));
Log.e("Longitud: ", (String.valueOf(loc.getLongitude())));
Log.e("Altitud: ", (String.valueOf(loc.getAltitude())));
Log.e("Precision: ", (String.valueOf(loc.getAccuracy())));
latitude_string = (String.valueOf(loc.getLatitude()));
longitude_string = (String.valueOf(loc.getLongitude()));
}else {
latitude_string = "";
longitude_string = "";
Toast.makeText(getApplicationContext(), "Ocurrio un error al capturar la ubicacion. No se guardo la ubicacion", Toast.LENGTH_LONG).show();
}
Enter the ELSE, that is, the permissions are there, but the result is that the variable loc = null