How can I use speech recognition without the annoying dialog in android phones
Use the SpeechRecognizer interface. Your app needs to have the RECORD_AUDIO permission, and you can then create a SpeechRecognizer, give it a RecognitionListener and then call its startListening
method. You will get callbacks to the listener when the speech recognizer is ready to begin listening for speech and as it receives speech and converts it to text.
Thanks for posting this! I found it helpful to define the onclick listener in oncreate:
@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mText = (TextView) findViewById(R.id.textView1); MyRecognitionListener listener = new MyRecognitionListener(); sr = SpeechRecognizer.createSpeechRecognizer(this); sr.setRecognitionListener(listener); findViewById(R.id.button1).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US"); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); sr.startListening(intent); } }); }