添加权限配置
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
添加依赖
implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.9.3'
请求代码
//获取蓝牙动态权限
RxPermissions rxPermissions = new RxPermissions(this.mContext);
rxPermissions.request(Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.BLUETOOTH,
Manifest.permission.CAMERA,
Manifest.permission.ACCESS_FINE_LOCATION).subscribe(
new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
Log.i(TAG, "请求结果:" + aBoolean);
}
}
);