The application is using gps.
MainActivity.java
protected void onStart() {
super.onStart();
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
//If you do not have permission
//Check if it is an initial permission request or a re-request by the user
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION) &&
ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.ACCESS_COARSE_LOCATION)) {
// If the user randomly revoked the permission
// Re-request permission
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 100);
return;
} } else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 100);
return;
}
}
}
```
OnStart() checks permissions and sets the next map view in fragment 1
mapView = new MapView(getActivity());
In this part
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
You will be forced to exit with these errors.
How do I check my authority?
Check the AndroidManifest.xml file to see if the permissions below have been added.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
© 2024 OneMinuteCode. All rights reserved.