android tv get started
TRANSCRIPT
![Page 1: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/1.jpg)
Android TV 入門
Ascii @ KKBOX
![Page 2: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/2.jpg)
ADT-1 Nexus Player
![Page 3: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/3.jpg)
Android TV SDK
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
}
}
dependencies {
compile 'com.android.support:leanback-v17:21.0.2'
}
![Page 4: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/4.jpg)
compileSdkVersion VS buildToolsVersion
![Page 5: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/5.jpg)
Nexus Player Controller
![Page 6: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/6.jpg)
Resolution
![Page 7: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/7.jpg)
Add TV Support 1
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:banner="@drawable/app_banner"
android:theme="@style/AppTheme" >
</application>
<activity
android:name=".TVMainActivity"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
![Page 8: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/8.jpg)
Add TV Support 2
![Page 9: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/9.jpg)
Common Errors
1. SDK Level (min 17)
2. Launch default Activity (Android Studio bug)
3. Unnecessary Resources (for mobile module)
4. uses-feature android:required="true" (false)
![Page 10: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/10.jpg)
Leanback Library
1. BrowseFragment
2. SearchFragment
3. DetailFragment
4. PlayFragmen
![Page 11: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/11.jpg)
BrowseFragment
public ListRow(HeaderItem header, ObjectAdapter adapter)
setBadgeDrawable(/*res*/);
![Page 12: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/12.jpg)
DetailFragment
DetailsOverviewRow.setAction(new Action(long id, CharSequence label))
OnActionClickedListener.
onActionClicked(Action action)
if (action.getId() == OPEN)
else if (action.getId() == UNIN)
else if (action.getId() == UPD)
![Page 13: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/13.jpg)
Create recommendations<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver
android:name=".recommendation.BootupActivity"
android:enabled="true"
android:exported="false" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
if (intent.getAction().endsWith(Intent.ACTION_BOOT_COMPLETED)) {
// startService(/* IntentService */) or getService(/* IntentService */)
}
![Page 14: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/14.jpg)
Create recommendations
public class RecommendationsService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
NotificationManager mNotificationManager = (NotificationManager)
getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new NotificationCompat.BigPictureStyle(
new NotificationCompat.Builder()).build();
mNotificationManager.notify(count, notification);
}
}
![Page 15: Android tv get started](https://reader036.vdocuments.net/reader036/viewer/2022081203/55a686541a28abd9088b4671/html5/thumbnails/15.jpg)
Reference
Design guideline
http://developer.android.com/design/tv/index.html
TV App Quality
http://developer.android.com/distribute/essentials/quality/tv.html
Publishing process
http://developer.android.com/distribute/googleplay/tv.html
Using the Leanback library
https://github.com/googlesamples/androidtv-Leanback
https://www.youtube.com/watch?v=72K1VhjoL98