Reputation: 276
I try to open a pairing dialog to a specific MAC address.
BluetoothDevice device;
String bt_mac = read.toUpperCase(Locale.GERMAN);
device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bt_mac);
Intent intent = new Intent("android.bluetooth.device.action.PAIRING_REQUEST");
intent.putExtra("android.bluetooth.device.extra.DEVICE", device);
intent.putExtra("android.bluetooth.device.extra.PAIRING_VARIANT", 0);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
But all I receive is this error message:
java.lang.SecurityException: Permission Denial: starting Intent { act=android.bluetooth.device.action.PAIRING_REQUEST flg=0x10000000 cmp=com.android.settings/.bluetooth.BluetoothPairingDialog (has extras) } from ProcessRecord{434110a0 15553:de.test.testapp/u0a10003} (pid=15553, uid=10003) not exported from uid 1000
I think the problem is this part of the message: not exported from uid 1000 But I don't know how to fix it
Upvotes: 1
Views: 2274
Reputation: 11
According to AndroidManifest.xml, the PAIRING REQUEST belongs to "special broadcasts that only the system can send":
<protected-broadcast android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
I guess that other users proposing this as a solution (e.g. in this question) might have root rights.
Upvotes: 0