WAI
Status Update
Comments
am...@google.com <am...@google.com> #2
Thank you for reporting this. We’ve shared this with our product and engineering teams and will continue to provide updates as more information becomes available.
am...@google.com <am...@google.com> #3
Customized paging on Android Auto is not supported. When the app is submitted for testing to move to production, the number of items will also need to be limited to comply with the Driver Distraction Guidelines.
Description
Long story short, the technique used in the post is to subscribe to the MediaBrowser and pass pagination intents. Then, the onLoadChildren method with the options argument is called:
public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result, @NonNull Bundle options) {
This works from the regular application. However, when calling the application from Android Auto, the regular method without the options argument is called:
public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result) {
As a result, it is impossible to paginate the results from Android Auto.
I did some experimentations with this project
===================================================================
--- final/src/main/java/com/example/android/musicplayercodelab/MusicPlayerActivity.java (revision d322b5a62b0da5afba209553bcccb660c12529d7)
+++ final/src/main/java/com/example/android/musicplayercodelab/MusicPlayerActivity.java (date 1551653654000)
@@ -57,7 +58,10 @@
new MediaBrowserCompat.ConnectionCallback() {
@Override
public void onConnected() {
- mMediaBrowser.subscribe(mMediaBrowser.getRoot(), mSubscriptionCallback);
+ Bundle extra = new Bundle();
+ extra.putInt(MediaBrowserCompat.EXTRA_PAGE, 0);
+ extra.putInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, 10);
+ mMediaBrowser.subscribe(mMediaBrowser.getRoot(), extra, mSubscriptionCallback);
try {
MediaControllerCompat mediaController =
new MediaControllerCompat(
@@ -100,7 +104,7 @@
new MediaBrowserCompat.SubscriptionCallback() {
@Override
public void onChildrenLoaded(
- String parentId, List<MediaBrowserCompat.MediaItem> children) {
+ String parentId, List<MediaBrowserCompat.MediaItem> children, @NonNull Bundle options) {
onMediaLoaded(children);
}
};
===================================================================
--- final/src/main/java/com/example/android/musicplayercodelab/MusicService.java (revision d322b5a62b0da5afba209553bcccb660c12529d7)
+++ final/src/main/java/com/example/android/musicplayercodelab/MusicService.java (date 1551653364000)
@@ -116,4 +117,10 @@
final String parentMediaId, final Result<List<MediaBrowserCompat.MediaItem>> result) {
result.sendResult(MusicLibrary.getMediaItems());
}
+
+ @Override
+ public void onLoadChildren(@NonNull String parentId, @NonNull Result<List<MediaBrowserCompat.MediaItem>> result, @NonNull Bundle options) {
+ result.sendResult(MusicLibrary.getMediaItems());
+ }
+
}
I observed the following:
the new onLoadChildren method with the options Bundle is called when starting the application normally. Interestingly, Android Auto calls the MusicPlayerActivity when it is launched, and calls connect() every time, so I definitely need to keep the call to connect(). This is important because it means that we do not have to try to get the MediaBrowser instance used by Android Auto unlike what we thought previously.
When opening the application it goes like this:
Call to connect()
Call to the onConnected callback and mMediaBrowser.subscribe(...) with the options
Call to onLoadChildren with options
From then, further calls are done to onLoadChildren with options
When opening Android Auto, it goes like this:
Call to connect()
Call to onLoadChildren without options
Call to the onConnected callback and mMediaBrowser.subscribe(...) with the options
Call to onLoadChildren with options
From then, when tapping on the headset in Android Auto, only onLoadChildren without options is called
Thus, I am not sure what to do next. Is there anything I can do on my side, or could it be an Android Auto bug?
Thank you!