Code example for BluetoothAdapter

Methods: closeProfileProxy

0
 
    @Override 
    public void onDestroy() { 
        super.onDestroy(); 
        Log.d(TAG, "Destroying HeadsetService...");
        mBluetoothAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset);
 
        unregisterReceiver(mProfileReceiver);
        mNotificationManager.cancel(NOTE_ID);
    } 
 
    public boolean startVoice() { 
        if (mBluetoothHeadset == null || mBluetoothHeadset.getConnectedDevices().isEmpty()) {
            //No valid connection to initiate 
            Toast.makeText(this, "Failed to Start Voice Recognition", Toast.LENGTH_SHORT).show();
            return false; 
        } 
 
        BluetoothDevice device = mBluetoothHeadset.getConnectedDevices().get(0);
        mBluetoothHeadset.startVoiceRecognition(device);
        return true;