Tuesday, 13 November 2018

Auto: Showing the progress while doing a background call

We have an audio app and we want to add Android Auto capability to it. The app basically has a list of radio streams and the user can select which one to play.

In order to obtain the streams, I need to call a web service and obtain the streams, while that is occurring I wish to show an indeterminate progress at least on the hamburger menu like Spotify does when it's loading content.

At this moment if I have already downloaded the streams, on my MediaBrowserServiceCompat when Auto calls onLoadChildren my Result<List<MediaBrowserCompat.MediaItem>> result object is populated with the MediaItems, if I don't have them I just send an empty array of MediaItems and call the API, once it has finished I call notifyChildrenChanged on the Service and the list of streams appear, but until then I have a "No items" message.

I could not find on Android Developer site a way to set the children menu to show a loading and I could not find a sample app that does that. Does anyone know if there's way, maybe when onGetRoot is called to let Auto know it has to wait before calling onGetRoot and onLoadChildren? I also tried calling the API then calling myself onGetRoot but it did not work.

Thanks in advance.



from Auto: Showing the progress while doing a background call

No comments:

Post a Comment