- YouTube video of this app, running on a Phone and TV (23s)
- YouTube video if this app, running on a TV, with D-Pad controls (20s)
Unsurprisingly Android TV is very much like the Android you know and love, and since NativeScript already runs like a champ on Android, you can easily support Android TV as well!
I found the easiest way to support TV devices is adding this line to your AndroidManifest.xml
and figuring out at runtime which UI to load.
You don't have to duplicate anything, but you really don't want to reuse phone layouts on your TV
for obvious reasons. So what this PoC does, is using a main-page.xml
for Phone / Tablet, and main-page-tv.xml
for TV to accomodate for the additional screen real estate - but they share the same main-view-model.ts
.
Sure you can, as those eventually render the same UI widgets as regular NativeScript does.
Nothing special there - iOS is powered by the same code that makes the Android Phone / Tablet version tick.
Ah, OK, ehm, please refer to this blog.
Create an Android TV emulator with the AVD manager inside Android Studio (if you're not so lucky to own a real device), then:
git clone https://github.com/EddyVerbruggen/nativescript-android-tv
cd nativescript-android-tv
npm i
tns run android