미디어 브라우저 서비스 수명 주기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 섹션에서는 일반적인 사용자 워크플로가 진행되는 과정에서 Android Automotive OS (AAOS) 및 Android Auto가 미디어 브라우저 서비스와 어떻게 상호작용하는지 설명합니다.
사용자가 AAOS 또는 Android Auto에서 앱을 실행합니다.
호스트 앱은 미디어 브라우저 서비스에 바인드되며, 이 서비스는 아직 실행 중이 아닌 경우 OS에서 시작합니다. onCreate()
메서드를 구현할 때 MediaSessionCompat
객체와 이 객체의 콜백 객체를 만들고 등록해야 합니다. 자세한 내용은 미디어 세션 등록을 참고하세요.
AAOS 또는 Android Auto에서는 서비스의 onGetRoot
메서드를 호출하여 콘텐츠 계층 구조의 루트를 가져옵니다. 루트가 표시되지 않습니다.
대신 후속 단계에서 앱에서 더 많은 콘텐츠를 가져옵니다.
AAOS 또는 Android Auto에서는 서비스의 onLoadChildren()
메서드를 호출하여 루트 미디어 항목의 하위 요소를 가져옵니다. AAOS와 Android Auto는 이러한 미디어 항목을 최상위 수준의 콘텐츠 항목으로 표시합니다. 시스템에서 예상하는 항목에 관한 자세한 내용은 루트 메뉴 구조화를 참고하세요.
사용자가 탐색 가능한 미디어 항목을 선택하면 서비스의 onLoadChildren()
메서드가 다시 호출됩니다.
사용자가 재생 가능한 미디어 항목을 선택하면 AAOS 또는 Android Auto에서 적절한 미디어 세션 콜백 메서드를 호출하여 작업을 실행합니다.
앱에서 지원하는 경우 사용자는 콘텐츠를 검색할 수도 있습니다. 이 경우 AAOS 또는 Android Auto에서는 서비스의 onSearch()
메서드를 호출합니다.
자세한 내용은 탐색 가능한 검색 결과 표시를 참고하세요.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-22(UTC)
[null,null,["최종 업데이트: 2025-08-22(UTC)"],[],[],null,["# Media browser service lifecycle\n\nThis section describes how Android Automotive OS (AAOS) and Android Auto\ninteract with your media browser service during a typical user workflow:\n\n1. The user launches your app on AAOS or Android Auto.\n\n2. The host app binds to your media browser service, which the OS starts if it\n isn't already running. In your implementation of the `onCreate()` method,\n you must create and register a [`MediaSessionCompat`](/reference/android/support/v4/media/session/MediaSessionCompat) object and its\n callback object. To learn more, see [Register a media session](/training/cars/media/enable-playback#registering_mediasession).\n\n3. AAOS or Android Auto calls your service's [`onGetRoot`](/training/cars/media/content-hierarchy#onGetRoot) method to\n retrieve the root in your content hierarchy. The root is not displayed.\n Instead, it retrieves more content from your app in subsequent steps.\n\n4. AAOS or Android Auto calls your service's [`onLoadChildren()`](/reference/androidx/media/MediaBrowserServiceCompat#onLoadChildren(java.lang.String,androidx.media.MediaBrowserServiceCompat.Result%3Cjava.util.List%3Candroid.support.v4.media.MediaBrowserCompat.MediaItem%3E%3E)%5D) method to\n retrieve the descendants of the root media item. AAOS and Android Auto\n display these media items as the top level of content items. See\n [Structure the root menu](/training/cars/media/content-media-browser/content-hierarchy#root-menu-structure) to learn more about what the system expects.\n\n5. When the user selects a **browsable** media item, your service's\n `onLoadChildren()` method is called again.\n\n6. If the user selects a **playable** media item, AAOS or Android Auto calls\n the appropriate media session callback method to perform the action.\n\n7. If supported by your app, the user can also search your content. In this\n case, AAOS or Android Auto call your service's [`onSearch()`](/reference/androidx/media/MediaBrowserServiceCompat#onSearch(java.lang.String,android.os.Bundle,androidx.media.MediaBrowserServiceCompat.Result%3Cjava.util.List%3Candroid.support.v4.media.MediaBrowserCompat.MediaItem%3E%3E)) method.\n To learn more, see [Display browsable search results](/training/cars/media/create-media-browser/browsable-search)."]]