Heim  >  Fragen und Antworten  >  Hauptteil

eclipse 提示 ContextCompat中不包含checkSelfPermission方法

如图

import android.support.v4.app.ActivityCompat;import android.support.v4.content.ContextCompat;

代码如下

private void requestPermission(String permission){
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
            if (ContextCompat.checkSelfPermission(BookListActivity.this, 
                    Manifest.permission.READ_EXTERNAL_STORAGE)
                            != PackageManager.PERMISSION_GRANTED) {

                            ActivityCompat.requestPermissions(BookListActivity.this,
                                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                                    MY_PERMISSIONS_REQUEST_READ_CONTACTS);

            }
        }
    }


高洛峰高洛峰2931 Tage vor1985

Antworte allen(1)Ich werde antworten

  • 三叔

    三叔2016-11-01 10:50:16

    android-support-v4.jar 是什么版本的checkSelfPermission方法在23.0.0及后续版本中才有

    Antwort
    0
  • StornierenAntwort