diff options
author | Renato Mangini <mangini@google.com> | 2014-10-08 18:32:55 -0700 |
---|---|---|
committer | Renato Mangini <mangini@google.com> | 2014-10-08 18:48:34 -0700 |
commit | 7c700e80b902c8f7778ffd63c287ac5710fd69ef (patch) | |
tree | 0edd92bb63af3ff17bdd6e188884cd94c98906cb /MusicDemo/src/main/java/com/example/android/musicservicedemo | |
parent | 7236969fa8d6fec5b6741e09549df335f2542e46 (diff) | |
download | demos-7c700e80b902c8f7778ffd63c287ac5710fd69ef.tar.gz |
Add slot reservation to Gearhead music sample.android-wear-5.0.0_r1android-cts-5.0_r9android-cts-5.0_r8android-cts-5.0_r7android-cts-5.0_r6android-cts-5.0_r5android-cts-5.0_r4android-cts-5.0_r3android-5.0.2_r3android-5.0.2_r1android-5.0.1_r1android-5.0.0_r7android-5.0.0_r6android-5.0.0_r5.1android-5.0.0_r5android-5.0.0_r4android-5.0.0_r3android-5.0.0_r2android-5.0.0_r1lollipop-wear-releaselollipop-releaselollipop-devlollipop-cts-release
Also add SmallIcon metadata.
B=17924045
Change-Id: I145d02efc871af5df4033053fab9375238fb93eb
Diffstat (limited to 'MusicDemo/src/main/java/com/example/android/musicservicedemo')
-rw-r--r-- | MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java b/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java index f7e9dfc..1950cd6 100644 --- a/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java +++ b/MusicDemo/src/main/java/com/example/android/musicservicedemo/MusicService.java @@ -166,6 +166,7 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe mWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_FULL, "MusicDemo_lock"); + // Create the music catalog metadata provider mMusicProvider = new MusicProvider(); mMusicProvider.retrieveMedia(new MusicProvider.Callback() { @@ -183,6 +184,23 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); + + // Use these extras to reserve space for the corresponding actions, even when they are disabled + // in the playbackstate, so the custom actions don't reflow. + Bundle extras = new Bundle(); + extras.putBoolean( + "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_NEXT", + true); + extras.putBoolean( + "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_SKIP_TO_PREVIOUS", + true); + // If you want to reserve the Queue slot when there is no queue + // (mSession.setQueue(emptylist)), uncomment the lines below: + // extras.putBoolean( + // "com.google.android.gms.car.media.ALWAYS_RESERVE_SPACE_FOR.ACTION_QUEUE", + // true); + mSession.setExtras(extras); + updatePlaybackState(null); mMediaNotification = new MediaNotification(this); @@ -771,6 +789,7 @@ public class MusicService extends MediaBrowserService implements OnPreparedListe * */ private void updatePlaybackState(String error) { + LogHelper.d(TAG, "updatePlaybackState, setting session playback state to " + mState); long position = PlaybackState.PLAYBACK_POSITION_UNKNOWN; if (mMediaPlayer != null && mMediaPlayer.isPlaying()) { |