What is the first argument of BrowserRoot()
which is a return type of onGetroot()
in MediaBrowserServiceCompat
.
Its first argument is rootId
which is a string ,so do I pass the path of my album ? How I do get its value ? How do I return a content hierarchy that is not null ?
@Override
public BrowserRoot onGetRoot(String clientPackageName, int clientUid,
Bundle rootHints) {
if (allowBrowsing(clientPackageName, clientUid)) {
return new BrowserRoot(MY_MEDIA_ROOT_ID, null); // what should I pass here ?
} else {
return new BrowserRoot(MY_EMPTY_MEDIA_ROOT_ID, null);
}
}
Any help is appreciated.
I use "root". Use any string, then in the load children, check if the parent id is "root" or an artist or album id, then pass the media items accordingly
edited to add some code from my onLoadChildren for clarity (note, the hashmaps can be lists, i use the hashmaps to easily set toolbar text using media ids mapped to artist/album names):
You can also change your root variable to playlist and check for that to get a list of playlists and use a list of playlist ids to get the members. Hope i helped
edited again just to put in my onGetRoot to show how simple mine is: