Skip to content

Instantly share code, notes, and snippets.

@mtbossa
Forked from miazga/howto.md
Created December 10, 2022 22:03
Show Gist options
  • Save mtbossa/bad896b2449d5a2fef44563e457d7b3a to your computer and use it in GitHub Desktop.
Save mtbossa/bad896b2449d5a2fef44563e457d7b3a to your computer and use it in GitHub Desktop.
Expo + Android TV

Applications built with Expo and React Native WILL NOT launch correctly unless proper configured.

This solves: https://forums.expo.io/t/rn-expo-build-for-android-tv/9403 and https://stackoverflow.com/questions/51707841/android-tv-app-shows-white-screen

1. For the Expo managed workflow update app.json:

"android": {
      ...
      "intentFilters": [
        {
          "action": "MAIN",
          "category": [
            "LEANBACK_LAUNCHER"
          ]
        }
      ]
    },

This will automatically update the AndroidManifest.xml .MainActivity with the following intent-filter:

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

2. For the bare workflow (e.g. ejected to ExpoKit):

Update android/app/src/main/AndroidManifest.xml with the following:

<activity
   android:name=".MainActivity"
   android:launchMode="singleTask"
   android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
   android:theme="@style/Theme.Exponent.Splash"
   android:windowSoftInputMode="adjustResize">
   ...
   <!-- ADD THE INTENT FILTER FROM BELOW TO LAUNCH APP ON ANDROID TV-->
   <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
   </intent-filter>
   ...
   <!-- ADD DETACH APP SPECIFIC INTENT FILTERS -->
</activity>

3. FYI

The problem is .experience.TvActivity run by default when launching on the Android TV launcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment