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

相关推荐
一起搞IT吧41 分钟前
相机拍照无响应问题分析一:【MEMORY_NOT_ENOUGH导致】持续快拍,一会儿无法拍照了
android·c++·数码相机·智能手机
是店小二呀1 小时前
【MySQL】MySQL 从安装到理解
android·mysql·adb
we1less2 小时前
[audio] threadLoop_write 到 audio-hal 分析
android
冬奇Lab4 小时前
一次必现ANR问题的深度分析与解决之旅:当NestedScrollView遇上VelocityTracker
android·性能优化·debug
三少爷的鞋5 小时前
2025 技术总结:我把技术重新结构化的一年
android
叶羽西5 小时前
查Google Android某个子仓库的修改情况
android
a176029317575 小时前
3DS模拟器 Azahar模拟器最新版 安卓汉化中文版+PC版附3DS中文游戏资源全集+3DS密匙key和字库
android·游戏
山山而川 潺潺如镜6 小时前
python防止程序多开,但程序运行脚本
android·开发语言·python
花开彼岸天~7 小时前
Flutter跨平台开发:Android View 在鸿蒙系统上的使用指南
android·flutter·harmonyos
子一!!7 小时前
MySQL==表的结构操作1
android·python·adb