Simplify Bluetooth Connectivity with bluetoothhelper

In the modern mobile-centric era, seamless connectivity is quintessential. The open-source project, bluetoothhelper, crafted by tlgbltcn, emerges as a boon for Android developers aiming to infuse Bluetooth capabilities into their applications. Employing the native Android API, bluetoothhelper stands out for its ease of use.

The crux of bluetoothhelper lies in its array of features:

  1. Toggle Bluetooth: Easily switch Bluetooth on or off with a simple command.
  2. Device Scanning: Venture into the vicinity to discover available Bluetooth devices.
  3. Device Connection: Establish a connection with a desired Bluetooth device swiftly.
  4. Data Transmission: Facilitate the sending and receiving of data over Bluetooth effortlessly.

Integration is straightforward, requiring only the import of the bluetoothhelper module into your Android application:

dependencies {
    implementation 'com.github.tlgbltcn:bluetoothhelper:1.7'
}

The provided code snippet unveils how uncomplicated it is to enable Bluetooth, initiate a scan for nearby devices, and establish a connection with a found device:

// ...rest of the code

// Enable Bluetooth
BluetoothHelper.enableBluetooth(this);

// ...rest of the code

// Connect to Bluetooth device
BluetoothHelper.connect(this, device);

// ...rest of the code

// Disable Bluetooth
BluetoothHelper.disableBluetooth(this);

// ...rest of the code

Aside from the core functionalities, bluetoothhelper doesn’t shy away from offering additional utilities like obtaining detailed information about a Bluetooth device and managing data transmission:

// Fetching Bluetooth device details
BluetoothDevice device = BluetoothHelper.getConnectedDevice(this);

// Sending data
String data = "Hello, world!";
BluetoothHelper.sendData(this, device, data);

// Receiving data
BluetoothHelper.setOnDataReceivedListener(this, device, (data) -> {
    // Process received data
});