Skip to content

Instantly share code, notes, and snippets.

@abdullahceylan
Forked from miazga/howto.md
Last active August 27, 2022 00:55
Show Gist options
  • Save abdullahceylan/6741a0837f55f16a817949ec2a451210 to your computer and use it in GitHub Desktop.
Save abdullahceylan/6741a0837f55f16a817949ec2a451210 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",
            "LAUNCHER"
          ],
          "data": {}
        }
      ]
    },

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