Auto中为媒体应用程序自定义问候消息

Auto中为媒体应用程序自定义问候消息

本文介绍了如何在Android Auto中为媒体应用程序自定义问候消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个Android自动媒体应用.当用户未登录时,如何做与Spotify相同的操作,并显示一条消息请登录以使用Spotify".我不会进行登录判断,我只想更改仪表板上显示的默认问候消息.默认情况下,媒体应用程序始终显示要播放某些内容,请打开菜单...."如何更改它?救命!

I'm currently developing one Android auto media app. How can I do the same as Spotify when users not login, to give a message "Please login to use spotify". I'm not gonna do a login judgement, I just want to change the default hello message shown on the dashboard. By default, the media app always show "To play something, open the menu...." How can I change it? Help!

推荐答案

您可以使用 setErrorMessage() .Builder.html"rel =" nofollow noreferrer> PlaybackStateCompat 类即可完成此操作.将PlaybackStateCompat分配给Media Session时,它用于描述播放器的当前操作状态.

You can use the setErrorMessage() in the PlaybackStateCompat class to accomplish this. When the PlaybackStateCompat is assigned to a Media Session, its used to describe the current operational state of the player.

private void playbackStateErrorMessage(int code, String message) {
    PlaybackStateCompat.Builder playbackStateBuilder = new PlaybackStateCompat.Builder();
    playbackStateBuilder.setState(PlaybackStateCompat.STATE_ERROR, -1L, 1.0F);
    playbackStateBuilder.setErrorMessage(code, message);
    mSession.setPlaybackState(playbackStateBuilder.build());
}

这篇关于如何在Android Auto中为媒体应用程序自定义问候消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 23:18