Tutorial by Examples

Add this permission to the manifest file to use Bluetooth features in your application: <uses-permission android:name="android.permission.BLUETOOTH" /> If you need to initiate device discovery or manipulate Bluetooth settings, you also need to add this permission: <uses-permi...
private static final int REQUEST_ENABLE_BT = 1; // Unique request code BluetoothAdapter mBluetoothAdapter; // ... if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_B...
private static final int REQUEST_DISCOVERABLE_BT = 2; // Unique request code private static final int DISCOVERABLE_DURATION = 120; // Discoverable duration time in seconds // 0 means always discoverable ...
Declare a BluetoothAdapter first. BluetoothAdapter mBluetoothAdapter; Now create a BroadcastReceiver for ACTION_FOUND private final BroadcastReceiver mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); //...
After you obtained BluetoothDevice, you can communicate with it. This kind of communication performed by using socket input\output streams: Those are the basic steps for Bluetooth communication establishment: 1) Initialize socket: private BluetoothSocket _socket; //... public InitializeSock...
The BluetoothLE API was introduced in API 18. However, the way of scanning devices has changed in API 21. The searching of devices must start with defining the service UUID that is to be scanned (either officailly adopted 16-bit UUID's or proprietary ones). This example illustrates, how to make an A...

Page 1 of 1