安卓:检查是否插入耳机 [英] Android: Checking if headphones are plugged in
问题描述
我如何检查是否插入耳机,在目前堵塞。我不想一个BroadcastReceiver它告诉我,当他们已经连接到设备上。我需要的是这样的:
如果(/ *耳机连接* /)
...
看起来你会感兴趣的<一个href="http://developer.android.com/intl/de/reference/android/media/AudioManager.html#isWiredHeadsetOn%28%29"><$c$c>isWiredHeadsetOn()$c$c>法和<一href="http://developer.android.com/intl/de/reference/android/media/AudioManager.html#isBluetoothA2dpOn%28%29"><$c$c>isBluetoothA2dpOn()$c$c>方法 <一个href="http://developer.android.com/intl/de/reference/android/media/AudioManager.html"><$c$c>AudioManager$c$c>类。
不过, isWiredHeadsetOn()
方法仅适用于Android的2.0或更高版本可用。 (该 isBluetoothA2dpOn()
方法由于Android 1.5可用。)
How can I check if headphones are currently plugged in. I don't want a broadcastreceiver which informs me when they have been connected to the device. I need something like:
if(/*headphone is connected*/)
...
It looks like you'll be interested in the isWiredHeadsetOn()
method and isBluetoothA2dpOn()
method of the AudioManager
class.
However, the isWiredHeadsetOn()
method is only available in Android 2.0 or later. (The isBluetoothA2dpOn()
method has been available since Android 1.5.)
这篇关于安卓:检查是否插入耳机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!