Droid难以置信耳机检测 [英] Droid Incredible Headphones Detection

查看:113
本文介绍了Droid难以置信耳机检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发的Droid难以置信Android应用程序。当我插上我的耳机,图标会显示在状态栏上,所以我presume手机必须知道耳机是present。

I'm developing an Android application for the Droid Incredible. When I plug in my headphones, an icon appears on the status bar, so I presume the phone must know headphones are present.

我的code产生蜂鸣声响应各种用户输入,但我今天这是一个非常糟糕的主意,当用户戴着耳机发现。噢。

My code produces beeps in response to various user inputs, but I discovered today that's a REALLY BAD idea when the user is wearing headphones. Ow.

是否有人对如何检测耳机presence编程,在Android的建议??

Does anybody have suggestions for how I can detect the presence of headphones programmatically, in Android??

谢谢,
R上。

Thanks, R.

推荐答案

我发现的 AudioManager 在开发者网站类,它看起来有这个一个有用的方法,但我没有测试它:

I found the AudioManager class on the developer site, it looks to have a helpful method for this, but I have not tested it:

AudioManager am = getSystemService(Context.AUDIO_SERVICE);
bool headsetEnabled = am.isWiredHeadsetOn();

这篇关于Droid难以置信耳机检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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