I'm trying to send txt file to connected device via bluetooth.
I found an answer here: Android bluetooth print stopped working on 4.1 (Blog)
After getting proper device a broadcast is send to notify that device was selected:
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);
}
The problem there is that android.bluetooth.devicepicker.action.DEVICE_SELECTED
is a special broadcast which only system can send so sendBroadcast(intent);
method throws SecurityException
saying
Permission Denial: not allowed to send broadcast android.bluetooth.devicepicker.action.DEVICE_SELECTED
Are there any workarounds or other ways to send files?