Android Automobile sample ========================= Integration points ------------------ MusicService.java is the main entry point to the integration. It needs to: - extend android.service.media.MediaBrowserService, implementing the media browsing related methods onGetRoot and onLoadChildren; - start a new MediaSession and notify it's parent of the session's token (super.setSessionToken()); - set a callback on the MediaSession. The callback will receive all the user's actions, like play, pause, etc; - handle all the actual music playing using any method your app prefers (for example, the Android MediaPlayer class) - update info about the playing item and the playing queue using MediaSession (setMetadata, setPlaybackState, setQueue, setQueueTitle, etc) - handle AudioManager focus change events and react appropriately (eg, pause when audio focus is lost) - declare a meta-data tag in AndroidManifest.xml linking to a xml resource with a root element. For a media app, this must include an element as a child. For example, in AndroidManifest.xml: And in res/values/automotive_app_desc.xml: - be declared in AndroidManifest as an intent receiver for the action android.media.browse.MediaBrowserService: Optionally, you can listen to special intents that notify your app when a car is connected/disconnected. This may be useful if your app has special requirements when running on a car - for example, different media or ads. See CarPlugReceiver for more information. Customization ------------- The car media app has only a few customization opportunities. You may: - Set the background color by using Android L primary color: - Add custom actions in the state passed to setPlaybackState(state) - Handle custom actions in the MediaSession.Callback.onCustomAction Known issues: ------------- - Sample: Resuming after pause makes the "Skip to previous" button disappear - Sample: playFromSearch creates a queue with search results, but then skip to next/previous don't work correctly because the queue is recreated without the search criteria - Emulator: running menu->search twice throws an exception. - Emulator: Under some circumstances, stop or onDestroy may never get called on MusicService and the MediaPlayer keeps locking some resources. Then, mediaPlayer.setDataSource on a new MediaPlayer object halts (probably) due to a deadlock. The workaround is to reboot the device.