How to detect if a microphone is present in android?
<p>I have a voice recognition part in my application to capture users voice input.</p>

<p>This is what I do</p>

<pre><code>Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
startActivityForResult(voiceIntent, REQUEST_CODE);
</code></pre>

<p>This works fine on most of the devices but now since the tablets are getting popular and some of them do not have a mic, it throws an error</p>

<blockquote>
  <p>W/dalvikvm(  408): threadid=1: thread
  exiting with uncaught exception
  (group=0x40015560) E/AndroidRuntime( 
  408): FATAL EXCEPTION: main
  E/AndroidRuntime(  408):
  android.content.ActivityNotFoundException:
  No Activity found to handle Intent {
  act=android.speech.action.RECOGNIZE_SPEECH
  (has extras) } E/AndroidRuntime( 
  408):     at
  android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
  .....</p>
</blockquote>

<p>So I want to detect if the microphone is present before I let the user access the voice input feature. How can I detect if a microphone is present on the device.</p>

<p>Thank you.</p>
