David Vedvick

Notes

June 17th, 2024

Targeting Multiple Form Factors on Android

If you'd want to target multiple form factors on Android for a single application, you suffer from a case of too many options:

  • Provide the same app:
    • Views that adapt to different view dimensions.
    • Views that render differently depending on flags given during the launch of the application (typically via intent).
  • Provide different apps:
    • Different product flavors or different modules:
      • Different application IDs.
      • Different version codes.

This means there are 6 (2 + 2*2) possible ways of providing a different application based on the deployed form factor. So how to choose the best?

First off, the "different apps design" seems mostly intended for completely different applications that share the same codebase; the fact that you can use it for different form factors seems to just be a nice side effect. This means that this approach really works best with different applications - with different application IDs, you don't need to worry about collisions when providing application artifacts on Google Play. The downside is that this leaves you with two separate apps as far as Google Play is concerned, or two different version code tracks. If you take the "different version code" and later consolidate your handheld and TV apps, with the TV app being on the "higher" version code track, users will have to for example uninstall the existing TV application. One thing to be aware of with this approach is that once set-up in the Google Play store, it is difficult to reverse.

The other approach is to modify your views given different view dimensions or different Intent information. For TV, for example, this can be discerned by launching a special activity that is filtered on the android.intent.category.LEANBACK_LAUNCHER intent category. While having a single app makes publishing to the app store easier, it does leave both your TV users and your handheld users with the whole app, even though they may not use large swaths of it. Sharing views between TV and handheld is harder than it seems, at least with Jetpack compose, as the API's between touch and D-Pad navigation are largely separate.

Regardless of approach, it feels like swimming upstream trying to have the same app in different form factors. The ideal would to be able to produce different applications per form-factor that can share application ID and version code. Absent that, I think the best approach is unfortunately to maintain a single application.

Note posted on Monday, June 17, 2024 10:54 PM CDT - link