我正在尝试使用react-native
中的PermissionsAndroid在运行时期间在Android M(API 23)上请求蓝牙权限。
我收到以下错误Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity
。关于如何解决这个错误的任何想法?
我的代码是
Bluetooth.js:
componentWillMount() {
...
this.checkAndGrantPermissions();
}
async checkAndGrantPermissions() {
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.LOCATION,
{
title: 'Cool Photo App Camera Permission',
message: 'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.'
});
}
我也试过这样做:
async checkAndGrantPermissions() {
await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.LOCATION,
{
title: 'Cool Photo App Camera Permission',
message: 'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.'
}
).then(() => {
}).catch((err) => {
console.log(err);
});
}
但后来我收到了这个错误:
{"framesToPop":1,"code":"E_INVALID_ACTIVITY","line":8001,"column":29,"sourceURL":"http://packager.xb-kvy.darkwata.pentaheliosapp.exp.direct:80/main.bundle?platform=android&dev=true&hot=false&minify=false"}