2016-08-18 19 views
1

Googleマップを使用しているAndroidスタジオの最初のアプリで作業しています。私は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; 
関連する問題