FatUglyProud FatUglyProud - 1 year ago 264
Android Question

Cannot resolve symbol for permissions

I'm working on my first app in Android Studio which is using Google Maps. I'm trying to check the permissions in the MapsActivity but I'm getting 'Cannot resolve symbol 'ACCESS_FINE_LOCATION''.

I don't know why this is happening and I'm a bit out of my depth.

Here's the MapsActivity.java:

package com.example.i329968.mapstests;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback

private GoogleMap mMap;

protected void onCreate(Bundle savedInstanceState)
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

public void onMapReady(GoogleMap googleMap)
mMap = googleMap;

// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));

// mMap.setMyLocationEnabled(true);

if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
// Show rationale and request permission.

In AndroidManifest.xml I have:

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

Thanks in advance.

Answer Source

Add to your code :

import android.Manifest;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download