When adding permissions to my manifest file, the xml below works fine.
<permission android:name="android.permission.ACCESS_FINE_LOCATION" />
However, when I tried this latest method, it didn't work.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Which one should I use? If it's the first one, why doesn't it work? How to fix it?
Additionally, I also get an exception regarding Android 6.0 runtime permissions:
java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.
When I try to add permissions to the String array to check permissions, Android Studio tells me that it cannot resolve Manifest.permission in the code below:
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
Solutip
For the first part, you should use <uses-permission>
according to the Android Devlopers site. . Try to make sure you declare the permission directly under <manifest>
the tag, not in <application>
the tag. It's hard to know what your problem is without seeing your entire manifest file. See the link I posted above for more info on how to declare permissions in your manifest.
<manifest ...>
<uses-permission android:name="android.permission.CAMERA"/>
<application ...>
...
</application>
</manifest>
Regarding your runtime permissions issue:
new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION};
Done