Home How to get the uuid for ble device in android
Reply: 1

How to get the uuid for ble device in android

subhashree sahoo
subhashree sahoo Published in 2018-02-14 09:57:47Z

I am new to android development. I am working with ble scanning,connection etc.I want to display specific ble device according to UUID. How can I scan ble device using UUID.

Sudhin Philip
Sudhin Philip Reply to 2018-02-14 11:42:10Z

You can use startScan (List<ScanFilter> filters, ScanSettings settings, ScanCallback callback) method inside class BluetoothLeScanner. Set the service UUID in the ScanFilter to display specific BLE devices according to UUIDs.

Example on scan:

public void startScan(final BleDeviceScanCallback callback) {
    mCallback = callback;

    List<ScanFilter> filters = new ArrayList<ScanFilter>();
    if (mServiceUuids != null && mServiceUuids.length > 0) {
        for (UUID uuid : mServiceUuids) {
            ScanFilter filter = new ScanFilter.Builder().setServiceUuid(
                    new ParcelUuid(uuid)).build();
    ScanSettings settings = new ScanSettings.Builder().build();

    mBleScanner = mBluetoothAdapter.getBluetoothLeScanner();
    if (mBleScanner != null) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
            mBleScanner.startScan(filters, settings, mScanCallback);
        } else {
            // Unless required permissions were acquired, scan does not start.
            if (BleUtils.isBLEPermission(mContext)) {
                mBleScanner.startScan(filters, settings, mScanCallback);

Refer more here

More API details can be found here.

Learn about Scan Filters here.

Google Bluetooth LE Central Application Example here.

Please Note: BluetoothAdapter.startLeScan method was deprecated in API level 21. use startScan(List, ScanSettings, ScanCallback) instead.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302004 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO