Code example for BluetoothHeadset

Methods: getConnectedDevicesstopVoiceRecognition

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; 
        } 
 
        BluetoothDevice device = mBluetoothHeadset.getConnectedDevices().get(0);
        mBluetoothHeadset.stopVoiceRecognition(device);
        return true; 
    } 
 
    private void buildNotification(String text) {
        Notification note = new Notification.Builder(this)
                .setContentTitle("BluetoothProxyService")
                .setContentText(text)
Experience pair programming with AI  Get Codota for Java