Android TV Integration Skill
Integration conventions for the StreamLayer GoogleTV/AndroidTV SDK that keep an AI agent's diff small and correct — shared setup with Android, screen offset delegate, focus/remote, and Leanback placement.
StreamLayer GoogleTV / AndroidTV SDK Integration
How to wire StreamLayer into an existing GoogleTV/AndroidTV app cleanly. Follow the rules — they prevent the common over-integration mistakes.
This page is the human-readable form of the streamlayer-androidtv-integration agent skill. Reference it from your AI agent alongside the streamlayer-docs MCP — see Integrate with an AI Agent.
Android TV shares the Android SDKGoogleTV and AndroidTV apps use the same
io.streamlayer:androidsdkpackage as mobile. For anything not called out as TV-specific below, follow the Android Integration Skill.
Pick the package
io.streamlayer:androidsdk+io.streamlayer:android-media3— same Maven dependencies as Android, added to your module-levelbuild.gradle.- Main UI element:
StreamLayerFragment, same as Android — no separate TV fragment class. - Requirements: Android Studio 4.0+, target SDK 33+, min SDK 21, Kotlin or Java.
Rules (do this)
-
Initialize once at launch, with TV defaults. Call
StreamLayer.initializeApp(this, SL_SDK_KEY)inApplication.onCreate(), thenStreamLayer.setGamificationOptions(...)to turn off mobile-oriented features that don't fit a 10-foot UI (global leaderboard, invites, onboarding), andStreamLayer.setCustomTheme(SLRTheme(mainTheme = ..., baseTheme = ...))to match your TV app's branding. InitializeStreamLayerMedia3Player.initSdk(this)right after.- ❌ Reusing your phone theme/gamification defaults unchanged on TV.
- ✅ TV-specific
SLRTheme+ gamification options disabled, set once inApplication.
-
Place
StreamLayerFragmentas a sibling of your Leanback player, not nested inside it. If you use the Leanback library (VideoSupportFragment/PlaybackSupportFragment), add theFragmentContainerView(android:tag="StreamLayerFragment") as its own view alongside the player fragment's container — don't nest it inside Leanback's row/adapter hierarchy, so D-pad focus can move cleanly between your rows and the StreamLayer Element. -
Implement the screen-offset delegate instead of fixed TV margins. Register an
SLRAppHost.DelegateviawithStreamLayerUI { delegate = appHostDelegate }and implementonScreenSizeChanged(size: SLRAppHost.SLRScreenSize)to resize/reposition your player (topMargin,bottomMargin,startMargin,endMargin,playerMinWidth,playerHeight,verticalBias,playerCornerRadius) when the StreamLayer Element opens — don't hardcode TV-safe-area margins yourself. -
Let the SDK own D-pad focus and remote input while its Element is active. Don't intercept
KEYCODE_DPAD_*events meant for the expanded Element, and don't force focus back to your Leanback rows while it's open. Let your normal focus environment resume once the Element collapses. -
Keep credentials and the diff simple. The SDK API Key is a public, client-side value from StreamLayer Studio — a
BuildConfigconstant is fine; don't add.envscaffolding. CallStreamLayer.createEventSession(eventId, timecodeProvider)when the user switches streams. Fit the Element around your existing TV player screen — don't restructure your Leanback browse/playback flow.
Gotchas
- Element looks like a phone app. Forgetting to disable mobile gamification options (leaderboard/invites/onboarding) and to set a TV
SLRThemeis the most common tell. - Fixed-margin layouts break on different TV sets. Use the
onScreenSizeChangedscreen-offset delegate instead of hardcoded dp margins — screen safe areas vary across GoogleTV/AndroidTV devices. - Focus traps. Don't override focus search to pull D-pad focus away from an open StreamLayer Element — the most common Leanback-specific pitfall.
StreamLayerFragmentused beforeinitializeApp()crashes — same as mobile Android; order matters inApplication.onCreate().- GoogleTV vs AndroidTV. They share the same OS and Play Store catalog — no separate build or SDK path is needed for either.
- Authoritative API details: the
streamlayer-docsMCP (search/fetch) and the Android Integration Guide.
Related
- Integrate with an AI Agent — Connect the MCP and prompt your agent to run this integration
- GoogleTV / AndroidTV Getting Started — TV-specific setup, requirements, and installation
- Android Integration Skill — The shared SDK setup Android TV builds on
- Layout Guide — Portrait, landscape, and L-bar layout setup
- Customizing Themes — Theme and style customization
Updated 16 days ago
