title: Why does SpeechRecognizer say that I have insufficient permissions even when I've specified the RECORD_AUDIO permission?
body: <p>I'm trying to get speech recognition in my app. I get a permissions error that says I need the RECORD_AUDIO permission but I've specified that in my manifest. I'm on Android L, building for that API version too (nothing lower). Here is the exact error:</p>
  
  <pre><code>03-09 22:43:58.996    1555-1576/com.google.android.googlequicksearchbox:search E/RecognitionService﹕ call for recognition service without RECORD_AUDIO permissions
  </code></pre>
  
  <p>What's up? Here's my code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.andrewstromme.myapp" &gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
  
          &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
          &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>from MainActivity.java:</p>
  
  <pre><code>public class MainActivity extends Activity implements RecognitionListener {
  private SpeechRecognizer mRecognizer;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mRecognizer = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
      mRecognizer.setRecognitionListener(this);
  }
  
  public void listenForSpeech() {
      Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
      intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass()
              .getPackage().getName());
      intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "say something");
      intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
              RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
      intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
      mRecognizer.startListening(intent);
  }
  
  void showToastMessage(String message){
      Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
  }
  
  @Override
  public void onReadyForSpeech(Bundle params) {
  
  }
  
  @Override
  public void onBeginningOfSpeech() {
      showToastMessage("start of speech");
  
  }
  
  @Override
  public void onRmsChanged(float rmsdB) {
  
  }
  
  @Override
  public void onBufferReceived(byte[] buffer) {
  
  }
  
  @Override
  public void onEndOfSpeech() {
  
  }
  
  @Override
  public void onError(int error) {
      if (error == SpeechRecognizer.ERROR_AUDIO) {
          showToastMessage("audio recording error");
      } else if (error == SpeechRecognizer.ERROR_CLIENT) {
          showToastMessage("client side error");
      } else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
          showToastMessage("insufficient permissions");
      } else if (error == SpeechRecognizer.ERROR_NETWORK) {
          showToastMessage("network error");
      } else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
          showToastMessage("network timeout");
      } else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
          showToastMessage("no speech match");
      } else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
          showToastMessage("recognizer busy");
      } else if (error == SpeechRecognizer.ERROR_SERVER) {
          showToastMessage("server error");
      } else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
          showToastMessage("no speech input");
      } else {
          showToastMessage("unknown error");
      }
  }
  
  @Override
  public void onResults(Bundle results) {
      String result = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION).get(0);
      TextView t = (TextView)findViewById(R.id.spokenText);
      t.setText(result);
  }
  
  @Override
  public void onPartialResults(Bundle partialResults) {
  
  }
  
  @Override
  public void onEvent(int eventType, Bundle params) {
  
  }
  }
  </code></pre>