FileDocCategorySizeDatePackage
BrowserService.javaAPI DocAndroid 5.1 API10572Thu Mar 12 22:22:44 GMT 2015com.example.android.musicservicedemo

BrowserService

public class BrowserService extends android.service.media.MediaBrowserService
Service that implements MediaBrowserService and returns our menu hierarchy.

Fields Summary
private static final String
TAG
public static final String
BROWSE_ROOT_BASE_PATH
public static final String
NOW_PLAYING_PATH
public static final String
PIANO_BASE_PATH
public static final String
VOICE_BASE_PATH
public static final String
AUTHORITY
public static final android.net.Uri
BASE_URI
public static final android.net.Uri
BROWSE_URI
public static final int
BROWSE_ROOT
public static final int
NOW_PLAYING
public static final int
PIANO
public static final int
VOICE
private static final android.content.UriMatcher
sUriMatcher
public static final String[]
MEDIA_CONTAINER_PROJECTION
private com.example.android.musicservicedemo.browser.MusicProvider
mMusicProvider
private android.media.session.MediaSession
mSession
Constructors Summary
Methods Summary
public voidonCreate()


    
       
        super.onCreate();

        mSession = new MediaSession(this, "com.example.android.musicservicedemo.BrowserService");
        setSessionToken(mSession.getSessionToken());
    
public voidonDestroy()

        super.onDestroy();
    
public android.service.media.MediaBrowserService.BrowserRootonGetRoot(java.lang.String clientPackageName, int clientUid, android.os.Bundle rootHints)

        return new BrowserRoot(BROWSE_URI.toString(), null);
    
public voidonLoadChildren(java.lang.String parentId, Result result)

        new Handler().postDelayed(new Runnable() {
                public void run() {
                    final ArrayList<MediaBrowser.MediaItem> list = new ArrayList();

                    for (int i=0; i<10; i++) {
                        MediaDescription.Builder bob = new MediaDescription.Builder();
                        bob.setTitle("Title " + i);
                        bob.setSubtitle("Summary " + i);
                        bob.setMediaId(Uri.withAppendedPath(BASE_URI,
                                Integer.toString(i)).toString());
                        list.add(new MediaBrowser.MediaItem(bob.build(),
                                MediaBrowser.MediaItem.FLAG_BROWSABLE));
                    }

                    result.sendResult(list);
                }
            }, 2000);
        result.detach();