public void cancelDiscovery() {
        mHandler.removeCallbacks(scanTimeoutCallback);

        if (mScanning) {
            Log.i(TAG, "Cancelling discovery process");
            BluetoothAdapter.getDefaultAdapter().stopLeScan(mCallback);
            mScanning = false;
            boolean success = mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mListener.onDiscoveryComplete();
                }
            });
            if (!success) {
                Log.e(TAG, "Failed to post Discovery Complete callback!");
            }
        } else {
            Log.e(TAG, "No discovery in progress");
        }
    }
public void cancelDiscovery ( ) { mHandler . removeCallbacks ( scanTimeoutCallback ) ; if ( mScanning ) { Log . i ( TAG , "Cancelling discovery process" ) ; BluetoothAdapter . getDefaultAdapter ( ) . stopLeScan ( mCallback ) ; mScanning = false ; boolean success = mHandler . post ( new Runnable ( ) { @ Override public void run ( ) { mListener . onDiscoveryComplete ( ) ; } } ) ; if ( ! success ) { Log . e ( TAG , "Failed to post Discovery Complete callback!" ) ; } } else { Log . e ( TAG , "No discovery in progress" ) ; } }
Cancel a scan currently in progress. If no scan is in progress, this method does nothing.