1

I created a sample project from Android Studio. While creating first it asked for Mobile App and I checked TV Project also. It created two modules in same project with name mobile and tv, both projects contains res,main,values folders respectively. When I try to run the project I can run any one and it creates separate apk for both. Is it possible to create one apk and run on both tv and mobile?

niqueco
  • 2,261
  • 19
  • 39
Ravi
  • 140
  • 1
  • 12
  • @Robert I am able to create two different apk. I wanted one apk for both Tv and Mobile. – Ravi Aug 24 '18 at 07:30

1 Answers1

6

It's totally possible to have just one APK for both mobile and Android TV. The "trick" is that the mobile launcher activity has in the manifest:

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

...while the Android TV activity has this:

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

You don't even need any special module configuration, it can just be the same module.

niqueco
  • 2,261
  • 19
  • 39