So I've been trying to get started on a simple GPS application but at some point I'm required to ask for user permission on locationManager methods
if (isNetworkEnabled) {
locationManager.requestLocationUpdates(
locationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (locationManager != null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
Latitude = location.getLatitude();
Longitude = location.getLongitude();
} //location
} //locationManager
} //isNetworkEnabled
I understand that there's a simple way to do it for API 23, but I'd like to target Android 4.0.
I've seen a documentation about it ( https://developer.android.com/training/permissions/requesting.html ) but I just don't quite understand how to apply it to my code. I know I'm supposed to use ActivityCompact and ContextCompact but I'm just not sure on how. Please help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.