Search code examples
androidandroid-intentandroid-tv

Supporting Android TV and reusing main activity


I have an app that I am wanting to be supported by Android TV (the app currently supports phone and tablet)

The main activity is pretty basic, and whilst it does have two text inputs (for an account login) I'm certain it is usable on Android TV (seems to work on the emulator, yet to test on a real Android TV).

So in this case, in my manifest, should I be setting an intent for both LAUNCHER and LEANBACK_LAUNCHER?

Or should I just set the intent for LEANBACK_LAUNCHER?


Solution

  • You need to specify both the categories:

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
    
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    

    BTW is not recommended to use the same activity layout:

    If you are modifying an existing app for use on TV, your app should not use the same activity layout for TV that it does for phones and tablets. The user interface of your TV app (or TV portion of your existing app) should provide a simpler interface that can be easily navigated using a remote control from a couch. For guidelines on designing an app for TV, see the TV Design guide. For more information on the minimum implementation requirements for interface layouts on TV, see Building TV Layouts.

    Reference:
    http://developer.android.com/training/tv/start/start.html#tv-activity