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

相关推荐
summerkissyou198716 小时前
Android - 摄像头 - hal - 开发教程,例子,常见问题,分析方法,解决方案
android
summerkissyou198717 小时前
Android 16 架构图
android
神龙天舞200118 小时前
MySQL 备库为什么会延迟好几个小时
android·数据库·mysql
码农coding21 小时前
android12 systemUI 之锁屏
android
圆山猫21 小时前
[Virtualization](三):RISC-V H-extension 与 Guest 执行模式
android·java·risc-v
爱笑鱼21 小时前
Binder(七):getCallingUid() 读到的是谁?clearCallingIdentity() 又清掉了什么?
android
2501_915909061 天前
iOS 应用反调试技详解术 检测调试器的原理与防护实践
android·ios·小程序·https·uni-app·iphone·webview
Lvan的前端笔记1 天前
AndroidX 完全入门指南
android·androidx
帅次1 天前
Android 应用高级面试:Window 近1年高频追问 18 题
android·面试·职场和发展
总捣什么乱11 天前
MySQL MySQL是怎么保证主备一致的?
android·mysql·adb