2016-08-18 5 views
1

Google지도를 사용하는 Android Studio에서 첫 번째 앱을 만들고 있습니다. MapsActivity에서 권한을 확인하려고하는데 'ACCESS_FINE_LOCATION'심볼을 해석 할 수 없습니다.권한에 대한 심볼을 확인할 수 없습니다.

나는 왜 이런 일이 일어나고 있는지, 나는 내 깊이에서 조금 벗어났다.

다음은 MapsActivity.java의 :의 AndroidManifest.xml에서

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; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_maps); 
     // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
     SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); 
    mapFragment.getMapAsync(this); 
    } 

    @Override 
    public void onMapReady(GoogleMap googleMap) 
    { 
     mMap = googleMap; 

     googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); 
     googleMap.setIndoorEnabled(true); 
     // 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.moveCamera(CameraUpdateFactory.newLatLng(sydney)); 

     // mMap.setMyLocationEnabled(true); 

     if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) 
     { 
      mMap.setMyLocationEnabled(true); 
     } 
     else 
     { 
      // Show rationale and request permission. 
     } 
    } 
} 

내가 가진 : 사전에

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

감사합니다.

답변

2

코드에 추가

import android.Manifest; 
관련 문제