Skip to content

Instantly share code, notes, and snippets.

@sidishere
Created December 24, 2019 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidishere/ed9ba67b73d85c34679389cf79fefa61 to your computer and use it in GitHub Desktop.
Save sidishere/ed9ba67b73d85c34679389cf79fefa61 to your computer and use it in GitHub Desktop.
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