@Override
 protected void onPause() {
   super.onPause();
   if (mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
     scanLeDevice(false);
   }
 }
 @Override
 protected void onResume() {
   super.onResume();
   if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
     Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
     startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
   } else {
     if (Build.VERSION.SDK_INT >= 21) {
       mLEScanner = mBluetoothAdapter.getBluetoothLeScanner();
       settings =
           new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
       filters = new ArrayList<ScanFilter>();
     }
     scanLeDevice(true);
   }
 }