Code example for BluetoothHeadset

Methods: isAudioConnected, startVoiceRecognition

1
 
                @Override 
                public void onTick(long millisUntilFinished) 
                { 
                    String log; 
                    if (mBluetoothHeadset.isAudioConnected(mConnectedHeadset)) 
                    {	 
//                    	mAudioManager.startBluetoothSco(); 
//                    	 
//                        MyRecognitionListener listener = new MyRecognitionListener(); 
//                	    final SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(getApplicationContext()); 
//                  	    sr.setRecognitionListener(listener); 
////              	    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
////              	    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 
////              	    intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication().getPackageName()); 
////                      sr.startListening(intent); 
                 	  // sr.startListening(RecognizerIntent.getVoiceDetailsIntent(getApplicationContext())); 
                        
                    	log = "\nonTick audio already connected"; //$NON-NLS-1$ 
                        
                    } 
                    else 
                    { 
                        // First stick calls always returns false. The second stick 
                        // always returns true if the countDownInterval is set to 1000. 
                        // It is somewhere in between 500 to a 1000. 
                        if (mBluetoothHeadset.startVoiceRecognition(mConnectedHeadset)) 
                        { 
                        	 
                            log = "\nonTick startVoiceRecognition returns true"; //$NON-NLS-1$ 
                        } 
                        else