search

Home  >  Q&A  >  body text

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);

            }
        }
    }


高洛峰高洛峰2972 days ago2011

reply all(1)I'll reply

  • 三叔

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

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

    reply
    0
  • Cancelreply