Created
December 24, 2019 10:37
-
-
Save sidishere/ed9ba67b73d85c34679389cf79fefa61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private BluetoothAdapter bluetoothAdapter; | |
Button scanButton; | |
private static final int REQUEST_ENABLE_BT = 1; | |
private ArrayAdapter<String> mNewDevicesArrayAdapter; | |
Setup oncreateFirst check if your smartphone supports BluetoothbluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); | |
if (bluetoothAdapter == null) { Toast.makeText(this, "Device does not support bluetooth", | |
Toast.LENGTH_SHORT).show(); | |
finish(); | |
} | |
else if (!bluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); | |
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment