我的QQ:934834037
//Android native.js的判断是否有权限
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
if (getActivity().checkSelfPermission(Manifest.permission.CAMERA) ==
PackageManager.PERMISSION_DENIED) {
requestPermissions(new String[]{Manifest.permission.CAMERA}, 1);
} else {
Intent intent = new Intent(getActivity(),
MipcaActivityCapture.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
}
} else {
Intent intent = new Intent(getActivity(), MipcaActivityCapture.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
doNext(requestCode, grantResults);
}
private void doNext(int requestCode, int[] grantResults) {
if (requestCode == 1) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
Intent intent = new Intent(getActivity(), MipcaActivityCapture.class);
startActivityForResult(intent, Activity.RESULT_FIRST_USER);
} else {
DialogUtils.getConfirmDialog(getContext(), "去设置", "取消", "设置权限", "是否去设置拍照权限",
new OnResultCallBack() {
@Override
public void onSuccess(Object object) {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.fromParts("package", getContext().getPackageName(),null));
startActivity(intent);
}
@Override
public void onFailure(int error_code) {
}
}).show();
}
}
}
白罂粟
- 发布:2019-06-01 18:24
- 更新:2019-06-01 18:24
- 阅读:1379
0 个评论
要回复文章请先登录或注册