@Override protected void onPause() { super.onPause(); scanLeDevice(false); mLeDeviceListAdapter.clear(); mLeDeviceListAdapter.notifyDataSetChanged(); }
void scanLeDevice(final boolean enable) { if (enable) { // Stops scanning after a pre-defined scan period. System.out.println("mBluetoothAdapter.startLeScan"); if (mLeDeviceListAdapter != null) { mLeDeviceListAdapter.clear(); mLeDeviceListAdapter.notifyDataSetChanged(); } if (!mScanning) { mScanning = true; mBluetoothAdapter.startLeScan(mLeScanCallback); } } else { if (mScanning) { mScanning = false; mBluetoothAdapter.stopLeScan(mLeScanCallback); } } }