gpt4 book ai didi

android - 卫星导航语音开始/停止时通知应用程序

转载 作者:行者123 更新时间:2023-11-30 02:44:48 25 4
gpt4 key购买 nike

我正在编写一个应用程序,它使用“MediaPlayer”类来播放音乐。

我想为用户提供在 Google map (或其他)中的卫星导航语音通话时应该发生什么的选项,例如暂时静音播放轨道。

如何让我的应用程序了解此类事件?例如。通过回调或 Intent?我什么都没找到,有可能吗?

最佳答案

Is it even possible?

可能不会。

黛安·哈克伯恩说:

The platform needs to have richer features for deciding which audio to do at various times. I don't think having maps send a broadcast is really a good solution for this, and likely to quickly become a mess for everyone.

回答以下问题:

Google Maps Broadcast Event for audible navigation instructions start and stop?

您可以在这里阅读简短的主题:Link .

话又说回来,这个线程已经超过 4 年了。


回复您的评论:

您可以使用 AudioManager.OnAudioFocusChangeListener 来监听另一个应用程序(在本例中为 Google map )请求音频焦点的时间。检查是否 focusChange == AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK ==> 降低播放音量为卫星导航语音让路 ==> 否则如果 focusChange == AUDIOFOCUS_GAIN ==> 将音量提高到正常等级。您可以在此处阅读有关 focusChange 常量的更多信息:AudioManager .我还建议您通读以下内容:Link

关于android - 卫星导航语音开始/停止时通知应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25249939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com