I am writing a test app that exercise the Bluetooth on an Android device. I want my test app to be able to make the device discoverable. Simple search lead me to something like this:
Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);
The problem with this method is that it will bring the User Permission dialog. See here
How to automate pressing YES or NO on the permission dialog?