Wednesday, February 1, 2017

How to check Android device supports BLE (Bluetooth Low Energy)

public void checkBluetoothSupport(){  
     // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to  
     // BluetoothAdapter through BluetoothManager.  
     final BluetoothManager bluetoothManager =  
         (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);  
     BluetoothAdapter mBluetoothAdapter = bluetoothManager.getAdapter();  
     // Checks if Bluetooth is supported on the device.  
     if (mBluetoothAdapter == null) {  
       Toast.makeText(context, "Device does not supports BLE", Toast.LENGTH_SHORT).show();  
       return;  
     }  
     else{  
      Toast.makeText(context, "Device supports BLE", Toast.LENGTH_SHORT).show();  
     }  
   }  

No comments :

Post a Comment