I'm trying to add Android Auto capability to my existing app. It's a messaging app, but some messages have an audio attachment. So far, I was successfully able to create a CarAppService
to display the messages themselves, but I can't seem to be able to get the audio playback to connect to the Android Auto (so that it's tied to a a media session and showing playback controls in the Android Auto dashboard).
I followed the instructions here, and I also tried using the new Media3 library (using sample code here), but neither one seems to activate the MediaBrowserService
(or MediaLibraryService
in case of Media3).
I have the foreground service permission and the browser service declared in the manifest
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<meta-data android:name="com.google.android.gms.car.notification.SmallIcon"
android:resource="@drawable/ic_auto_icon" />
<service
android:name=".auto.MediaService"
android:foregroundServiceType="mediaPlayback"
android:exported="true">
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService"/>
<action android:name="android.media.browse.MediaBrowserService"/>
</intent-filter>
</service>
and I have the MediaLibraryService
all set with creating a media session, using my existing ExoPlayer
instance, and being initialized with the proper MediaLibrarySession.Callback
. But the `onCreate()' method of the MediaLibraryService (or MediaBrowserService) never gets called.
What am I missing? Is there something that I need to do in the car app itself to make it bind to the media browser service?