title: Can't get voice commands on Android Auto Media App work
body: <p>I have an Android App with working Auto capabilities which has been rejected from the store because:</p>
  
  <p>"Your app does not support all of the required voice commands.
  For example, your app does not contain an Intent filter for action "android.media.action.MEDIA_PLAY_FROM_SEARCH"."</p>
  
  <p>So i looked to at least make the app respond to "play music on X app" but by looking at the documentation I can't get it to work. I added this to my main activity (which is not the launcher activity, it controls the service via binder)</p>
  
  <pre><code>&lt;intent-filter&gt;
    &lt;action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" /&gt;
    &lt;category android:name="android.intent.category.DEFAULT" /&gt;
  &lt;/intent-filter&gt;
  </code></pre>
  
  <p>which triggers a <code>MediaBrowserServiceCompat</code>which is initialized this way:
  manifest:</p>
  
  <pre><code>&lt;service
              android:name=".Services.RadioService"
              android:enabled="true"
              android:exported="true"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.media.browse.MediaBrowserService" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  </code></pre>
  
  <p>part of the code:</p>
  
  <pre><code>   @Override
      public void onCreate() {
          super.onCreate();
          audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
          mSession = new MediaSessionCompat(this, "RService");
          mSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS
                  | MediaSessionCompat.FLAG_HANDLES_QUEUE_COMMANDS);
          mSession.setCallback(mCallback);
          mSessionConnector = new MediaSessionConnector(mSession);
          setSessionToken(mSession.getSessionToken());
          setMediaBrowser();
          initializeReceiver();
          C_F_App.createNotificationChannelPlayer(getApplicationContext());
          rNController = new RadioNotificationController(this, mSession, getApplicationContext());
      }
  
  final MediaSessionCompat.Callback mCallback =
              new MediaSessionCompat.Callback() {
                  @Override
                  public void onPlayFromMediaId(String mediaId, Bundle extras) {
                      playForAuto(mediaId);
                  }
  
                  @Override
                  public void onPlayFromSearch(String query, Bundle extras) {
                      super.onPlayFromSearch(query, extras);
                      Log.d("Test", "Test");
                  }
  
                  @Override
                  public void onStop() {
                      playPause();
                  }
  
                  @Override
                  public void onPlay() {
                      playPause();
                  }
  
                  @Override
                  public void onPause() {
                      playPause();
                  }
              };
  
  public void setMediaBrowser() {
      mediaBrowser = new MediaBrowserCompat(getApplicationContext(),
              new ComponentName(getApplicationContext(), this.getClass()),
              new MediaBrowserCompat.ConnectionCallback() {
                  @Override
                  public void onConnected() {
                      super.onConnected();
                  }
  
                  @Override
                  public void onConnectionSuspended() {
                      super.onConnectionSuspended();
                  }
  
                  @Override
                  public void onConnectionFailed() {
                      super.onConnectionFailed();
                  }
              }, null);
  
      mediaBrowser.connect();
  }
  
  @Override
  public long getSupportedPrepareActions() {
      return PlaybackStateCompat.ACTION_PREPARE_FROM_MEDIA_ID |
              PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID |
              PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH |
              PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH;
  }
  </code></pre>
  
  <p>Auto capabilities work fine.</p>
  
  <p>When i try to call this app on Auto from the emulator to play music it just does't do anything, it does not say errors or other stuff, it just closes google speak and then returns to the normal display. The method <code>onPlayFromSearch</code> is never called and it should be the one Auto would call if a voice command is sent.</p>
  
  <p>Can someone help me figure out what i'm doing wrong? Google doc is pretty useless this way, Google UAP doesen't look to have this capability like the old version but looking at the old UAP version i cannot figure out what I'm doing wrong.</p>
  
  <p>PS. The app is not published yet with this functionality</p>
  
  <p>Thanks in advance.</p>