In google maps I want to implement the button myCurrentLocation. In the onCreate method added the following:

googleMap.setMyLocationEnabled(true); 

And also in AndroidManifest 'e indicated the necessary permission ' s:

 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

But still underlines googleMap.setMyLocationEnabled(true); with the following error: enter image description here

    1 answer 1

    API 23 introduced so-called. runtime permissions and now for obtaining some permissions is not enough entries in AndroidManifest.xml .

    All permissions are divided into two types: normal and dangerous .

    To obtain permissions from the normal group, a corresponding entry in AndroidManifest.xml sufficient.

    To get permissions from the group dangerous except for the corresponding entry in the AndroidManifest.xml file, you must also run to request this permission from the user in runtime .

    ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION are classified as dangerous , therefore, to obtain these permission, you must additionally ask the user about it.

    On how to request permissions, a detailed answer is given here and in the official documentation .

    • Thanks, but the implementation is significantly different from what I have already written, and what is to be written. - Morozov