安卓TvView显示hdmi-in画面

1.布局

复制代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.media.tv.TvView
        android:id="@+id/tv_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"  />

</RelativeLayout>

2.主界面代码

复制代码
TvInputManager  tvInputManager = (TvInputManager) getSystemService(TV_INPUT_SERVICE);
List<TvInputInfo> list = tvInputManager.getTvInputList();
TvView mTvView = findViewById(R.id.tv_view);
mTvView.reset();
Uri uri = buildChannelUriForPassthroughInput(list.get(0).getId());
new Handler().postDelayed(() -> mTvView.tune(list.get(0).getId(),uri),1000);

功能其实很简单, mTvView.tune(list.get(0).getId(),uri) 这一句需要延迟一点,可能跟加载uri速度有关系,不延迟的话显示不了.

相关推荐
Android轮子哥12 分钟前
Android 12 SplashScreen 一种另类的适配方案
android·github
粤M温同学43 分钟前
Android OkHttp 下载限速方案实现
android·okhttp
2501_915106322 小时前
Perfdog 成本变高之后,Windows 上还能怎么做 iOS APP 性能测试
android·ios·小程序·https·uni-app·iphone·webview
愤怒的代码2 小时前
从开发调试到生产上线:全维度 Android 内存监控与分析体系构建
android·java·kotlin
jzlhll1232 小时前
Android最简化发布模块到mavenCentral
android·mavencentral
2501_915106323 小时前
iOS 安装了证书,HTTPS 还是抓不到
android·网络协议·ios·小程序·https·uni-app·iphone
好奇龙猫3 小时前
【人工智能学习-AI-MIT公开课13.- 学习:遗传算法】
android·人工智能·学习
TO_ZRG3 小时前
Unity打包安卓、iOS知识点
android·unity·android studio
周杰伦fans3 小时前
AndroidStudioJava国内镜像地址gradle
android·java·android-studio
艾莉丝努力练剑3 小时前
【Linux进程控制(一)】进程创建是呼吸,进程终止是死亡,进程等待是重生:进程控制三部曲
android·java·linux·运维·服务器·人工智能·安全