Cannot resolve Manifest.permission.ACCESS_FINE_LOCATION

前端 未结 12 980
天涯浪人
天涯浪人 2020-12-04 23:13

When adding permissions to my manifest file, the below xml works.

 
相关标签:
12条回答
  • 2020-12-04 23:58

    Try this:

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_SELECT_PICTURE);
            return;
        }
    
    0 讨论(0)
  • 2020-12-04 23:58

    When you type "Manifest", Android Studio should suggest you to choose a few options of Manifest. You should choose the one start android instead of the name of your project.

    If you access the reference of Manifest.java and you can find there is only 1-2 lines in "Permission" class, then you are referencing the wrong manifest class.

    0 讨论(0)
  • 2020-12-05 00:01

    I had a similar problem where used;

    ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED 
    

    where it could not resolve symbol READ_CONTACTS.

    However on using;

    import android.Manifest;
    

    It started to recognize READ_CONTACT

    0 讨论(0)
  • 2020-12-05 00:03
    new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
    

    change it to

    android.manifest.permission.ACCESS_FINE_LOCATION
    
    0 讨论(0)
  • 2020-12-05 00:07

    Try this before running, make sure you have permission to access..

    try {
        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    } catch (SecurityException e) {
       dialogGPS(this.getContext()); // lets the user know there is a problem with the gps
    }
    
    0 讨论(0)
  • 2020-12-05 00:14

    Change

    new String[]{Manifest.permission.ACCESS_FINE_LOCATION}
    

    To this

    new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}
    

    Your problem will be resolved.

    0 讨论(0)
提交回复
热议问题