프로젝트 설정

이 페이지에서는 자동차 앱 라이브러리를 설치하고 앱의 매니페스트 파일을 구성하는 방법을 설명합니다.

자동차 앱 라이브러리 설치

앱에 라이브러리를 추가하려면 Jetpack 라이브러리 출시 페이지를 참고하세요.

앱의 매니페스트 파일 구성

자동차 앱을 만들려면 먼저 앱의 매니페스트 파일을 구성해야 합니다.

CarAppService 선언

호스트는 CarAppService 구현을 통해 앱에 연결됩니다. 매니페스트에서 이 서비스를 선언하면 호스트에서 앱을 검색하여 연결할 수 있습니다.

앱 인텐트 필터의 <category> 요소에서 앱의 카테고리도 선언해야 합니다. 이 요소에 허용되는 값은 지원되는 앱 카테고리 목록을 참고하세요.

다음 코드 스니펫은 매니페스트에서 관심 장소 앱의 자동차 앱 서비스를 선언하는 방법을 보여줍니다.

<application>
    ...
   <service
       ...
        android:name=".MyCarAppService"
        android:exported="true">
      <intent-filter>
        <action android:name="androidx.car.app.CarAppService"/>
        <category android:name="androidx.car.app.category.POI"/>
      </intent-filter>
    </service>

    ...
<application>

지원되는 앱 카테고리

CarAppService 선언에 설명된 대로 CarAppService를 선언할 때 인텐트 필터에 이러한 값 중 하나 이상을 추가하여 앱의 카테고리도 선언해야 합니다.

각 카테고리에 대한 자세한 설명과 카테고리 자격 요건은 자동차용 Android 앱 품질을 참고하세요.

앱 이름 및 아이콘 지정

시스템 UI에서 앱을 나타내려면 carPermissionActivityLayout가 호스트의 앱 이름과 아이콘을 지정해야 합니다. CarAppServicelabelicon 속성을 사용하여 호스트가 앱을 표시하는 데 사용하는 앱 이름과 아이콘을 지정합니다.

...
<service
   android:name=".MyCarAppService"
   android:exported="true"
   android:label="@string/my_app_name"
   android:icon="@drawable/my_app_icon">
   ...
</service>
...

<service> 요소에서 라벨이나 아이콘을 선언하지 않으면 호스트는 <application> 요소에 지정된 값으로 대체합니다.

맞춤 테마 설정하기

자동차 앱의 맞춤 테마를 설정하려면 다음 단계를 따르세요.

  1. 매니페스트 파일에 <meta-data> 요소를 추가합니다.

    <meta-data
        android:name="androidx.car.app.theme"
        android:resource="@style/MyCarAppTheme />
    
  2. 스타일 리소스를 선언하여 맞춤 자동차 앱 테마의 속성을 설정합니다.

    <resources>
      <style name="MyCarAppTheme">
        <item name="carColorPrimary">@color/my_primary_car_color</item>
        <item name="carColorPrimaryDark">@color/my_primary_dark_car_color</item>
        <item name="carColorSecondary">@color/my_secondary_car_color</item>
        <item name="carColorSecondaryDark">@color/my_secondary_dark_car_color</item>
        <item name="carPermissionActivityLayout">@layout/my_custom_background</item>
      </style>
    </resources>