headset

AudioManager.isWiredHeadsetOn() is not working in android

两盒软妹~` 提交于 2019-12-01 05:36:48
I want to check whether heaset is plugged in or not... I did it like this AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE); Log.i("am.isWiredHeadsetOn()", am.isWiredHeadsetOn()+""); But i am always getting false value... Why is this happening? It looks like this is a bug. You will always get false when calling isWiredHeadsetOn unless your add MODIFY_AUDIO_SETTINGS permission to AndroidManifest.xml : <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 来源: https://stackoverflow.com/questions/6249884/audiomanager-iswiredheadseton-is-not-working-in-android

Invoking a private (unpublished) method in Android API

风流意气都作罢 提交于 2019-11-30 14:42:50
I need to check which BT headsets are currently connected (not just paired) in OS 2.0 - 2.3. Such functionality doesn't exist until API version 11, where a Bluetooth Headset class was introduced. But there already existed a class called BluetoothHeadset in prior APIs, but it wasn't publicly accessible. Here's the documentation for it: http://www.kiwidoc.com/java/l/x/android/android/9/p/android.bluetooth/c/BluetoothHeadset . So, I was trying to use reflection to invoke the "isConnected" method, but I'm pretty horrible at reflection, and I'm getting an error java.lang.IllegalArgumentException:

Accepting a Call via Bluetooth Headset

流过昼夜 提交于 2019-11-30 11:48:12
i am working on a VoIP-Android-App. I would like to accept and decline Calls via a connnected Bluetooth Headset in an Activity. What I have tried so far: Using a Media Session to receive Media Button clicks. Problem: If we start BluetoothSCO we do not receive any Media Button clicks. If we do not start BluetoothSCO we do receive Media Button clicks but we cannot differentiate long and short button clicks because downtime is always 0, the keycode is always KEYCODE_MEDIA_PLAY and the ACTION_DOWN is immediately followed by ACTION_UP. Those problems only occur if we are connected via Bluetooth. If

Android connect to a paired bluetooth headset

杀马特。学长 韩版系。学妹 提交于 2019-11-30 07:46:19
I want to simulate the action of going throgh Settings->Wireless->Bluetooth and connect a paired bluetooth headset programmatically. I've done some search in Stackoverflow and Google, both indicating that there is no solution available before API level 11. However, I'm interested in working it out by peeking in the source code of bluetooth implementation of Android. The problem is that I'm not aware of which specific source code I should review. Any suggestions? Many thanks. OK, I got this updated to support Honeycomb and up. You need to add new functions to the interface. I did that here:

How to detect if a bluetooth headset plugged or not IOS 8?

一世执手 提交于 2019-11-30 07:38:59
In my project, I use AVAudioSession to detect any headphone is plugged or unplugged. But in this case, I can't detect when bluetooth device is plugged. Here is my code for headphone state. - (void)audioRouteChangeListenerCallback:(NSNotification*)notification { NSDictionary *interuptionDict = notification.userInfo; NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue]; switch (routeChangeReason) { case AVAudioSessionRouteChangeReasonNewDeviceAvailable: //NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable"); NSLog(@"Headphone/Line

Broadcast receiver highest priority not working

吃可爱长大的小学妹 提交于 2019-11-30 04:51:20
问题 I'm doing an application using ACTION_MEDIA_BUTTON handler, but it appears it is always intercepted by MX Player or Apollo and I get no Intent I've tried both 1000 and 2147483647 priority set in tag and directly after constructor with setPriority Applications works when no MX Player or Apollo is present I've also tried using Headset Interceptor app from google play, I tried to deny events to MX Player with Autostarts application - nothing helps in onCreate: IntentFilter filter = new

How to make Android phone as a bluetooth headset?

蓝咒 提交于 2019-11-29 22:23:59
Yes, I know Android has already implemented the Bluetooth Headset Profile, but it is in Audio Gateway Role, not in HeadSet Role. What I want to do is develop an application on Android phone which will act as a bluetooth headset, so it can connect to my laptop by bluetooth. When I try to call somebody, I can use my phone to dial him, and my application will forward the voice through bluetooth to my laptop, and one other application running on laptop will get the voice data and forward them to Skype or GTalk or some VoIP program else. In other words, how can I implement the Headset Profile in

Invoking a private (unpublished) method in Android API

馋奶兔 提交于 2019-11-29 21:57:38
问题 I need to check which BT headsets are currently connected (not just paired) in OS 2.0 - 2.3. Such functionality doesn't exist until API version 11, where a Bluetooth Headset class was introduced. But there already existed a class called BluetoothHeadset in prior APIs, but it wasn't publicly accessible. Here's the documentation for it: http://www.kiwidoc.com/java/l/x/android/android/9/p/android.bluetooth/c/BluetoothHeadset. So, I was trying to use reflection to invoke the "isConnected" method,

Accepting a Call via Bluetooth Headset

天涯浪子 提交于 2019-11-29 18:08:34
问题 i am working on a VoIP-Android-App. I would like to accept and decline Calls via a connnected Bluetooth Headset in an Activity. What I have tried so far: Using a Media Session to receive Media Button clicks. Problem: If we start BluetoothSCO we do not receive any Media Button clicks. If we do not start BluetoothSCO we do receive Media Button clicks but we cannot differentiate long and short button clicks because downtime is always 0, the keycode is always KEYCODE_MEDIA_PLAY and the ACTION

Android connect to a paired bluetooth headset

元气小坏坏 提交于 2019-11-29 10:28:37
问题 I want to simulate the action of going throgh Settings->Wireless->Bluetooth and connect a paired bluetooth headset programmatically. I've done some search in Stackoverflow and Google, both indicating that there is no solution available before API level 11. However, I'm interested in working it out by peeking in the source code of bluetooth implementation of Android. The problem is that I'm not aware of which specific source code I should review. Any suggestions? Many thanks. 回答1: OK, I got