小编Nar*_*ddy的帖子

对于ContextCompat类型,方法checkSelfPermission(Context,String)是未定义的

Context context;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Context context = (Permission) this;
    // In an actual app, you'd want to request a permission when the user
    // performs an action
    // that requires that permission.
    if (Build.VERSION.SDK_INT >= 23) {
        getPermissionToReadUserContacts();
    }
}

// Identifier for the permission request
private static final int READ_CONTACTS_PERMISSIONS_REQUEST = 1;

// Called when the user is performing an action which requires the app to
// read the
// user's contacts
public …
Run Code Online (Sandbox Code Playgroud)

android android-activity android-permissions android-6.0-marshmallow

5
推荐指数
1
解决办法
2万
查看次数