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

相关推荐
冬奇Lab1 小时前
NotificationManagerService:通知管理与优先级控制
android·性能优化·源码阅读
Flywith244 小时前
【每日一技】Raycast 实现 scrcpy 的快捷显示隐藏
android·前端
没有了遇见5 小时前
Android(Coil,Glide)大量图片加载缓存清理问题(二 Coil处理)
android
城东米粉儿6 小时前
Android Dagger2笔记
android
没有了遇见6 小时前
Android(Coil,Glide)大量图片加载缓存清理问题(一)
android
恋猫de小郭6 小时前
谷歌 Genkit Dart 正式发布:现在可以使用 Dart 和 Flutter 构建全栈 AI 应用
android·前端·flutter
曾经我也有梦想7 小时前
Day4 Kotlin 高级特性
android
simplepeng8 小时前
Compose Multiplatform 中的 Navigation 3
android
Kapaseker13 小时前
一杯美式讲完 Sealed Class
android·kotlin
冬奇Lab1 天前
PowerManagerService(下):Doze模式与电池优化
android·源码阅读