检查Android的麦克风正在由另一个应用程序 [英] Check if Android mic is being used by another app

查看:1374
本文介绍了检查Android的麦克风正在由另一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查使用了Android麦克风的噪声水平。然而在访问麦克风之前,我想知道,如果麦克风正在由另一个应用程序访问。我如何检查,如果麦克风正被其他应用程序访问?

I want to check the noise level using the android mic. However before accessing the mic I want to know if the mic is being accessed by another application. How do I check if the mic is being accessed by another application?

推荐答案

有关活动的输入流以及它们的路由所拥有的信息在 AudioFlinger AudioPolicyManager AudioHardware 情况下,不共享此信息与应用。
该AudioManager类提供了一个 isMicrophoneMute()方法的应用,但话筒很可能静音,而这是不使用的,所以这种方法并没有真正告诉你是否有什么麦克风目前正在使用或不

Information about active input streams and where they are routed is held by the AudioFlinger, AudioPolicyManager and AudioHardware instances, which do not share this information with applications.
The AudioManager class provides an isMicrophoneMute() method to applications, but the mic may very well be unmuted while it's unused, so that method doesn't really tell you anything about whether the mic currently is being used or not.

,以找出是否有路由到麦克风的任何输入流的一种可能方法是做对 media.audio_policy A dumpsys和媒体。 audio_flinger 和解析输出。但风险在于,输出将眼光放在不同的设备不同,再加上我不知道,如果你被允许倾倒非根设备上这些服务的状态。

One possible way to find out if there are any input streams routed to the microphone is to do a dumpsys on media.audio_policy and media.audio_flinger and parse the output. But the risk is that the output will look different on different devices, plus I don't know if you're allowed to dump the status of those services on a non-rooted device.

这篇关于检查Android的麦克风正在由另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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