I have the following in my manifest:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I also have the location permission set in my phone's settings.
Yes, GPS is enabled on the phone.
Here, I check for the permission:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
int hasLocationPermission = mContext.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
Log.d(TAG, "location permission: " + hasLocationPermission); // 0
if (hasLocationPermission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(mContext, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
hasLocationPermission = mContext.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION);
Log.d(TAG, "location permission: " + hasLocationPermission); // still 0
}
If I have the permission in my manifest and in my phone's settings for the app, why is it still preventing me from accessing the location? It is returning 0.0 for both latitude and longitude because of this.