The permissions defined in the Manifest.xml to use geolocation are:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET"/>
If your device is Android 6.0 you must request the permissions in this way:
Before calling the requestLocationUpdates()
method, you must perform the permissions check in this way (in this example, your Activity must extend from AppCompatActivity:
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
//Requiere permisos para Android 6.0
Log.e("Location", "No se tienen permisos necesarios!, se requieren.");
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 225);
return;
}else{
Log.i("Location", "Permisos necesarios OK!.");
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, (LocationListener) mlocListener);
}