Ravi
Ravi

Reputation: 139

Is it possible to create one APK and run on Android TV and Mobile App?

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?

Upvotes: 1

Views: 2330

Answers (1)

niqueco
niqueco

Reputation: 2408

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.

Upvotes: 7

Related Questions