有没有其他参数可以使用来代替checkSelfPermission()
.我想用 API 22 编译我的代码。但checkSelfPermission()
仅支持 API 级别 23 及更高。
步骤 1:导入包
import android.support.v4.app.ActivityCompat;
第 2 步:检查权限
ActivityCompat.requestPermissions(Class.this, new String[]permission},requestCode);
步骤 3:授予权限后,您可以调用
@Override
public void onRequestPermissionsResult() {
}