当另一个应用程序在Android中使用麦克风时,无法访问麦克风 [英] Unable to access microphone when another app is using it in Android

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

问题描述

我正在使用以下URL中的代码,以便从带有AudioRecord的麦克风获取声音数据:
http://www.dreamincode.net/forums/topic/303235-visualizing-sound-from-the-microphone/

I'm using code from the following URL in order to get sound data from the microphone with AudioRecord: http://www.dreamincode.net/forums/topic/303235-visualizing-sound-from-the-microphone/

我看到的问题是,如果另一个应用程序也在使用麦克风,我会从AudioRecord中收到一个错误(状态-3)。如果我杀死正在使用麦克风的其他应用,一切都会按预期进行。是否有一个优雅的解决方案,即使其他应用已经在使用它,也允许我的应用访问麦克风?

The problem I'm seeing is that if another app is also using the microphone, I'm getting an error (status -3) from AudioRecord. Everything works as expected if I kill the other app which is using the microphone. Is there an elegant solution to allow my app to access the microphone even if another app is already using it?

谢谢。

推荐答案

可悲的是,只有一个应用一次可以访问麦克风(就像摄像头一样)。

Sadly, only one app at a time can access the microphone (just like the camera).

此外,没有标准的方式通知另一个应用您想要访问麦克风(以便他们释放资源并让您访问它)。但是,您可以向所有其他应用程序发送广播(请求麦克风),但是其他应用程序必须实现此功能(很少或零个开发人员可以执行此功能)。

Also, there is no standard way to inform another app that you want access to the microphone (so that they release the resources and let you access it). You could however send a broadcast to all other apps ("requesting the microphone"), but the other apps would have to implement this feature (and very few or zero developers will do this).

我建议您仅通知用户,因为您无法执行其他操作,因此麦克风当前不可用。

I would recommend you to simply inform the user that the microphone is currently not available, because you can't do anything else.

这篇关于当另一个应用程序在Android中使用麦克风时,无法访问麦克风的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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