[英]Permission Denial: not allowed to send broadcast android.bluetooth.device.action.FOUND
I am trying to sendbroadcast. 我正在尝试广播。 After execution, I get following error: 执行后,出现以下错误:
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.bluetooth.device.action.FOUND from pid=24885, uid=10370 java.lang.SecurityException:权限拒绝:不允许从pid = 24885,uid = 10370发送广播android.bluetooth.device.action.FOUND
If anyone has experience with this error, your kind help will be appreciated. 如果有人遇到此错误,将为您提供帮助。 Here is my method: 这是我的方法:
private void DiscoverOBDConnection() {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.startDiscovery();
// Create a BroadcastReceiver for ACTION_FOUND
final List<String> discoverableDevicesList = new ArrayList<String>();
final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
intent=new Intent(BluetoothDevice.ACTION_FOUND);
String action = intent.getAction();
// When discovery finds a device
sendBroadcast(intent);
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
discoverableDevicesList.add(device.getName() + "\n" + device.getAddress() + "\n");
String discoveredDeviceName = device.getName();
}
}
}
};
mReceiver.onReceive(this, new Intent(BluetoothDevice.ACTION_FOUND));
} }
manifest permissions: 清单权限:
<uses-permission android:name="android.permission.BLUETOOTH"/>
add admin permission to access bluetooth 添加管理员权限以访问蓝牙
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.