android - 我的Android移动应用程序无法在android电视上运行

标签 android android-studio android-layout error-handling television

大家好,我首先为我的android手机制作了我的应用程序,但是当我在自己的android电视上安装时,这出现了一个错误,它在我的android TV上不起作用,但是此应用程序在我的手机上运行良好,我该如何运行我在android电视上的应用有任何建议,请大家帮我\
我的电视android版本是4.4.2,而移动android版本是9
谢谢。

这是我的应用程序的 list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.oxoo.spagreen"
    tools:ignore="MissingLeanbackLauncher">

    <uses-feature
        android:name="android.software.leanback"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />

    <application
        android:name=".utils.MyAppClass"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        android:screenOrientation="landscape"
        tools:ignore="GoogleAppIndexingWarning">
        <activity android:name=".WebViewActivity"
            android:screenOrientation="landscape"
            android:theme="@style/FullscreenTheme"></activity>

        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-8804184340526788~7833821786" />
        <meta-data
            android:name="com.onesignal.NotificationOpened.DEFAULT"
            android:value="DISABLE" />
        <meta-data
            android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
            android:value="com.google.android.exoplayer2.ext.cast.DefaultCastOptionsProvider" />

        <activity
            android:name=".TermsActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".ReplyActivity"
            android:label="@string/title_activity_reply"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".ProfileActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".PassResetActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".SearchActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".SignUpActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".LoginActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".DetailsActivity"
            android:configChanges="screenLayout|screenSize|orientation"
            android:label="@string/title_activity_details"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.NoActionBar" /> <!-- android:configChanges="screenLayout|screenSize|orientation" -->
        <activity
            android:name=".MainActivity"

            android:theme="@style/AppTheme.Nobar"
            android:screenOrientation="landscape"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".SettingsActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".SplashscreenActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:screenOrientation="landscape"
            android:theme="@style/FullscreenTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ItemMovieActivity"
            android:label="@string/title_activity_item_show"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".ItemTVActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
        <activity
            android:name=".ItemSeriesActivity"
            android:screenOrientation="landscape"
            android:theme="@style/AppTheme.Nobar" />
    </application>

</manifest>
and here is the build.gradle of my app


buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}


apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.oxoo.spagreen"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 13
        versionName "1.1.3"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        manifestPlaceholders = [
                onesignal_app_id: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha05'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0-beta01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-beta01'

    implementation 'com.google.android.material:material:1.1.0-alpha06'
    implementation 'androidx.legacy:legacy-support-v13:1.0.0'
    implementation 'androidx.vectordrawable:vectordrawable:1.1.0-beta01'
    implementation 'androidx.browser:browser:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05'


    implementation 'com.facebook.shimmer:shimmer:0.4.0'
    implementation 'com.balysv:material-ripple:1.0.2'                  // ripple effect

    implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.volley:volley:1.1.1'

    // retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'

    implementation 'com.google.android:flexbox:0.3.2'

    implementation 'com.onesignal:OneSignal:3.10.5'
    implementation 'com.hootsuite.android:nachos:1.1.1'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'

    implementation 'de.hdodenhof:circleimageview:3.0.0'

    implementation 'com.google.android.gms:play-services-ads:17.2.0'

    implementation 'com.google.android.exoplayer:exoplayer-core:2.7.3'
    implementation 'com.google.android.exoplayer:exoplayer-dash:2.7.3'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.7.3'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.7.3'
    implementation 'com.google.android.exoplayer:extension-rtmp:2.7.3'
    implementation 'com.google.android.exoplayer:extension-cast:2.7.3'
    implementation 'com.github.HaarigerHarald:android-youtubeExtractor:master-SNAPSHOT'
    implementation 'com.google.android.libraries.cast.companionlibrary:ccl:2.8.4'

    implementation 'com.github.ixiDev:GDPRChecker:v0.2'
    implementation 'com.google.android.ads.consent:consent-library:1.0.7'
}

最佳答案

对于Android TV应用,您首先应提供专用横幅,以便可以在Android TV启动器中显示该应用图标。另请:https://developer.android.com/training/tv/start/start.html#banner

另外,我看不到Leanback的任何意图过滤器:

<activity
    android:name=".SplashscreenActivity"
    android:configChanges="orientation|keyboardHidden|screenSize"
    android:screenOrientation="landscape"
    android:theme="@style/FullscreenTheme">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
    </intent-filter>
</activity>

您可能需要创建两个单独的intent-filter(一个用于移动设备,另一个用于电视)。

请注意,即使应用程序运行良好,移动设备(触摸屏)和电视(使用 Controller )之间的导航也可能会影响用户体验,并不意味着它与电视体验完全兼容。请查看此文档以获取更多信息:https://developer.android.com/training/tv/

关于android - 我的Android移动应用程序无法在android电视上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60014865/

相关文章:

android - 如何使用水平 ScrollView / ListView 添加动态图像

Android:如何清除自定义 ListView 中的所有项目

java - 找不到符号变量 edit_message

java - 如何让我的微调器与我的 EditText 具有相同的宽度?

android - 升级Android Studio 3.6或更高版本

java - 底部导航 View 随着 windowSoftInputMode=adjustResize 上升

android - 为什么要使用操作栏?

android - 在TabLayout下的AppBarLayout中添加自定义阴影?

android - 如何根据语言环境显示日期格式?

java - android/java在项目中组织http web服务调用的结构/模式是什么?