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

相关推荐
消失的旧时光-19438 小时前
Android ADB指令大全详解
android·adb
ashcn200110 小时前
opengl 播放视频的android c++ 方案
android·c++ opengl es
abner.Li10 小时前
android 反编译
android
Digitally10 小时前
如何删除 realme 手机上的短信
android
2501_9160088910 小时前
提高 iOS 应用逆向难度的工程实践,多工具联动的全栈安全方案
android·安全·ios·小程序·uni-app·cocoa·iphone
沐怡旸10 小时前
【底层机制】Android图形渲染体系深度解析:VSync信号机制
android·面试
BoomHe11 小时前
Android 13 (API 33)上自定义广播
android
来来走走12 小时前
Android开发(Kotlin) ViewModel基本用法
android·开发语言·kotlin
Digitally12 小时前
在荣耀手机上删除短信的完整指南
android
nono牛13 小时前
Android Binder C/C++ 层详解与实践
android·c语言·binder