简体   繁体   中英

Android Google Maps location permission

I'm trying to get my current location. According to the Android docs, I'm supposed to use this:

if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);

Unfortunately, the Manifest.permission.ACCESS_FINE_LOCATION part is not working for me. I seem to have a Manifest class, and a 'permission' subclass.... but nothing beyond that.... so ACCESS_FINE_LOCATION cannot be found and I'm getting a "cannot resolve symbol ACCESS_FINE_LOCATION" error. I found a 'Manifest.java' file with the definition of permission... but nothing about ACCESS_FINE_LOCATION. It seems like I should add something to that 'Manifest.java' file, but there's a note at the top saying that the file was automatically generated and I shouldn't mess with it...

尝试添加以下行:

import android.Manifest;

尝试使用android.permission而不是manifest.permission

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM