Skip to content

Instantly share code, notes, and snippets.

@miazga
Last active March 23, 2024 16:59
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save miazga/2e6449e0c591e3ac8e22185b2edb447d to your computer and use it in GitHub Desktop.
Save miazga/2e6449e0c591e3ac8e22185b2edb447d 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.

@arslantopcu1
Copy link

hi 👋 @aldebaran80 did you find any answer ?

@wardbeyens
Copy link

I have the same question

@silencer07
Copy link

silencer07 commented Feb 20, 2024

For those who are looking for android banner config:

react-native-tvos/IgniteTV@0a29a6d

context: expo/expo#27142 (comment)

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