下面是请求摄像头的权限“:
注意这里的PERMISSION_DENIED 是属于PackageManager的
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
if(Build.VERSION.SDK_INT>=23){
int p = checkSelfPermission(android.Manifest.permission.CAMERA);
if(p== PackageManager.PERMISSION_DENIED)
requestPermissions(new String[]{android.Manifest.permission.CAMERA},998);
}else{
checkPermission(android.Manifest.permission.CAMERA, Binder.getCallingPid(),Binder.getCallingUid());
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
StringBuilder sb = new StringBuilder();
for(int i=0;i<permissions.length;i++){
sb.append(permissions[i].toString()+";");
}
Log.d("Kodulf","getPermission"+sb);
}