安卓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速度有关系,不延迟的话显示不了.

相关推荐
雨白11 分钟前
OkHttp 源码解析:enqueue 非同步流程与 Dispatcher 调度
android
风往哪边走1 小时前
自定义仿日历组件弹框
android
没有了遇见1 小时前
Android 外接 U 盘开发实战:从权限到文件复制
android
Monkey-旭2 小时前
Android 文件存储机制全解析
android·文件存储·kolin
zhangphil2 小时前
Android Coil 3拦截器Interceptor计算单次请求耗时,Kotlin
android·kotlin
DokiDoki之父3 小时前
多线程—飞机大战排行榜功能(2.0版本)
android·java·开发语言
用户2018792831675 小时前
强制关闭生命周期延时的Activity实现思路
android
用户2018792831675 小时前
Activity后生命周期暂停问题
android
用户2018792831675 小时前
浅析:WindowManager添加的 View 的事件传递机制
android
顾林海5 小时前
从"面条代码"到"精装别墅":Android MVPS架构的逆袭之路
android·面试·架构