repositories {
jcenter() // If not already there
}
dependencies {
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.0@aar'
}
dependencies {
compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.8.2@aar'
}
RxPermissions.getInstance(this)
.request(permissions)
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean granted) {
if (granted) { // 在android 6.0之前会默认返回true
// 已经获取权限
String jpgPath = getCacheDir() + "test.jpg";
takePhotoByPath(jpgPath, 2);
} else {
// 未获取权限
Toast.makeText(MainActivity.this, "您没有授权该权限,请在设置中打开授权", Toast.LENGTH_SHORT).show();
}
}
});
RxView.clicks(findViewById(R.id.request_permission))
.compose(RxPermissions.getInstance(this).ensure(Manifest.permission.CAMERA))
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean granted) {
if (granted) { // 在android 6.0之前会默认返回true
// 已经获取权限
String jpgPath = getCacheDir() + "test.jpg";
takePhotoByPath(jpgPath, 2);
} else {
// 未获取权限
Toast.makeText(MainActivity.this, "您没有授权该权限,请在设置中打开授权", Toast.LENGTH_SHORT).show();
}
}
});
RxPermissions.getInstance(MainActivity.this).request(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean granted) {
if (granted) { // 在android 6.0之前会默认返回true
// 已经获取权限
String jpgPath = getCacheDir() + "test.jpg";
takePhotoByPath(jpgPath, 2);
} else {
// 未获取权限
Toast.makeText(MainActivity.this, "您没有授权该权限,请在设置中打开授权", Toast.LENGTH_SHORT).show();
}
}
});
RxPermissions.getInstance(MainActivity.this).requestEach(Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO)
.subscribe(new Action1<Permission>() {
@Override
public void call(Permission permission) {
if (permission.name.equals(Manifest.permission.CAMERA)) {
if (permission.granted) {
String jpgPath = getCacheDir() + "test.jpg";
takePhotoByPath(jpgPath, 2);
} else {
// 未获取权限
Toast.makeText(MainActivity.this, "您没有授权该权限,请在设置中打开授权", Toast.LENGTH_SHORT).show();
}
} else if (permission.name.equals(Manifest.permission.RECORD_AUDIO)) {
}
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有