如何在Android TV主屏幕上为当前正在运行的任务设置图标和标题 [英] How to set the icon and title on Android TV home screen for the currently running task

查看:315
本文介绍了如何在Android TV主屏幕上为当前正在运行的任务设置图标和标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已根据以下指南为Android TV应用启用了画中画模式:

I have enabled picture-in-picture mode for an Android TV app based on this guide: https://developer.android.com/guide/topics/ui/picture-in-picture.html

当我进入PiP模式并导航到Android主屏幕的主屏幕时,它将在顶部显示当前正在运行的任务(PiP窗口),并带有图标标题和打开和关闭选项.

When I enter PiP mode, and navigate to the home screen of the Android home screen, it shown at the top the currently running task (PiP window) with an icon an title and options to Open and Close.

我找不到有关如何设置标题和图标(但最重要的是标题)的任何文档.我尝试设置 ActivityManager.TaskDescription ,但是没有任何运气.另外请注意,我确实在清单中设置了应用标题,但是此处未显示.另外请注意,在任务切换器中,应用程序标题和图标正确显示.

I could not find any documentation on how to set the the title and the icon (but most importantly the title). I have tried setting the ActivityManager.TaskDescription but without any luck. Also note that I do have an app title set in the Manifest, but that is not being shown here. Also note that in the task switcher, the app title and icon is shown correctly.

有什么想法如何从屏幕截图中设置(No title program)?

Any ideas how to set the (No title program) from the screenshot?

已在Android TV API 26、27上进行了测试,因为画中画仅自奥利奥后才可用.

Tested on Android TV API 26, 27, as Picture-in-Picture is only available since Oreo.

推荐答案

如果实现MediaSession,则会显示标题.系统评估MediaSession的方式类似于在电话上使用MediaSession进行通知的方式.

If you implement MediaSession, the title will appear. The system evaluates the MediaSession similar to how notifications with MediaSession work on phones.

有一个演示的活动 MediaSession如何影响android-PictureInPicture示例中的PIP操作.这是示例中的错误,感谢您对其进行记录.

There is an activity that demonstrates how MediaSession can affect PIP actions in the android-PictureInPicture sample. This is a bug in the sample, thank you for logging it.

要显示标题,您将需要在媒体会话上更新元数据.

To get the title to appear, you will need to update the meta data on the media session.

MediaMetadataCompat metadata = new MediaMetadataCompat.Builder()
            .putString(
                 MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, 
                "Big Buck Bunny")
            ...
            .build();
mSession.setMetadata(metadata);

这篇关于如何在Android TV主屏幕上为当前正在运行的任务设置图标和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆