Code example for BluetoothHeadset

Methods: getConnectedDevices, startVoiceRecognition

0
        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; 
    } 
 
    public boolean stopVoice() { 
        if (mBluetoothHeadset == null || mBluetoothHeadset.getConnectedDevices().isEmpty()) {
            //No valid connection to initiate 
            Toast.makeText(this, "Failed to Stop Voice Recognition", Toast.LENGTH_SHORT).show();
            return false;