我正在尝试通过蓝牙将txt文件发送到连接的设备。
我在这里找到了答案:Android bluetooth print stopped working on 4.1(Blog)
获取正确的设备后,会发送广播通知该设备已被选中:
private void sendDevicePickedIntent(BluetoothDevice device) {
Intent intent = new Intent(ACTION_DEVICE_SELECTED);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
if (mLaunchPackage != null && mLaunchClass != null) {
intent.setClassName(mLaunchPackage, mLaunchClass);
}
sendBroadcast(intent);
}
问题是android.bluetooth.devicepicker.action.DEVICE_SELECTED
是special broadcast which only system can send所以sendBroadcast(intent);
方法抛出SecurityException
说
权限拒绝:不允许发送广播android.bluetooth.devicepicker.action.DEVICE_SELECTED
是否有任何变通方法或其他方式来发送文件?