Android TV APP으로 정의
Manifest.xml
android.intent.category.LEANBACK_LAUNCHER"
정의 해야함
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.leanback">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
앱 아이콘 등록
기본적으로 Android는
상위와 같은 형태로 App Icon을 표시하는데 TV 용 아이콘은 Banner를 사용한다
이미지 사이즈는 배너는 크기가 320 x 180픽셀인 xhdpi 리소스 로 정의해서 처리 하면 된다.
그런데 216 x 122 픽셀로 해도 문제가 없는거 같다.
android:banner = "@drawable/videos_by_google_banner"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.leanback">
<application
android:allowBackup="true"
android:banner = "@drawable/videos_by_google_banner"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
안드로이드TV와 일반 안드로이드 단말의 앱이 호환 되는 경우와 안드로이드 TV만 사용하는 앱으로 설정 할 수 있는 방법이 있는데 다음과 같이 feature를 설정해 주면 된다.
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
여기서 touchscreen은 Optional 인데 TV의 경우 기본적으로 touchscreen 사용을 전제 하지 않는 다고 생각 하면 된다.
Optional이 맞긴한데 touchscreen을 true로 할 경우 appstore에 표시 해 주지 않는다고 한다.
leanback의 설정 여부는 다음과 같다.
- true : leanback을 지원하는 기기에서만 사용가능한 앱. 즉 안드로이드TV만 지원
- false : 일반 단말과 안드로이드 TV 둘다 지원
다음과 같이 Leanback Theme를 적용한다.
android:theme="@style/Theme.Leanback"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.leanback">
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<application
android:allowBackup="true"
android:banner = "@drawable/videos_by_google_banner"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Leanback">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
이와 같이 적용 하면 아래와 같이
테마 설정이 가능하다.
Leanback의 다음 기능을 사용하기 위해서는 다음과 같이 라이브러리를 build.gradle에 포함시켜줘야 한다.
androidx.leanback.app
androidx.leanback.database
androidx.leanback.graphics
androidx.leanback.media
androidx.leanback.preference
androidx.leanback.system
androidx.leanback.widget
androidx.leanback.widget.picker
implementation 'androidx.leanback:leanback:1.0.0'
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.example.leanback"
minSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.leanback:leanback:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
'Android' 카테고리의 다른 글
fastboot 로 device를 찾을 수 없을때 해결방법 (2) | 2021.05.06 |
---|---|
Android System Server (Activity Finish) (0) | 2021.03.31 |
AOSP system app install (0) | 2020.08.20 |
Android Grafika Texture Surface (0) | 2020.03.27 |
android memory leak 처리 (0) | 2020.03.27 |