android - React Native - Android TV - DPad 功能

标签 android reactjs react-native google-play-console

我已经为 android tv 发布了一个 react native 应用到 google play store。

对于电视,我收到了以下通知:

Missing DPad functionality Your app requires user interaction for menus or app navigation. Please make sure that all menus and app navigation are fully functional using a DPad. Please refer to our DPAD Control and Hardware Declaration documentation.

我们如何为 react-native android 应用启用方向键导航?

如果您需要更多信息,请告诉我。

最佳答案

最后,我解决了 react 原生 android tv 应用程序的方向键导航和横幅问题。

问题是:(这包括甚至不属于问题一部分的问题)

<强>1。没有全尺寸应用横幅

修复: "your-app/android/app/src/main/res"下创建一个名为 drawable 的文件夹 ,添加一个 png 文件(尺寸 320px x 180px 和 320 dpi),最重要的部分是,在图像中,有除了您发布 APK 的应用程序名称 之外,不应有其他文本。

<强>2。不支持的硬件使用

修复: 我在发布问题之前修复了这个问题,但是如果您遇到这个问题,

refer the answer by **@reidisaki** on this question.

<强>3。缺少 DPad 功能(问题中提出的实际问题)

修复:我在屏幕上使用 InputText。好吧,在 android/android tv 的 react-native version 0.56 下,InputText 无法通过 d-pad 聚焦(方向键)。 我停止使用 TextInput,它修复了方向键导航。它也可以在 Android 模拟器中使用,以测试应用程序。

为了让我的应用程序更兼容电视,在 AndroidManifest.xml 中,我将 Activity 启动器升级为:

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

将主题升级为 Android TV 的 Leanback:

  1. 添加了 leanback library 到 dependencies 部分下的“app-name/android/app/build.gradle”:

    dependencies {
    ....
    compile "com.android.support:leanback-v17:${rootProject.ext.supportLibVersion}"
    }
    
  2. AndroidManifest.xml 中,我将主题更改为 @style/Theme.Leanback

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:banner="@drawable/banner"
      android:allowBackup="true"
      android:theme="@style/Theme.Leanback">
      ....
    </application>
    

关于android - React Native - Android TV - DPad 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51888892/

相关文章:

Android Studio 无法解析符号错误

android - 使用 Paint 绘制 HTML

javascript - Reactjs 在类外但在同一个文件中访问类方法

javascript - 当我将组件从无状态转换为有状态时,数据没有及时读取;

react-native - 如何使用 fetch() 和 React Native 处理 set-cookie header

React Native 中的 Android Activity 生命周期 - ViewPager

android - 在Android中将电话号码格式化为E164格式

reactjs - '--watchAll=false' 和 'CI=true' 有什么区别?

react-native - react 本 map 标

android - (Android) 为什么 invalidate() 不会立即更新我的按钮?