Iphone How to find out if a Bluetooth headset is connected

using iphone sdk 3.1.2.

In any case, is it known whether a Bluetooth headset is connected to the device? No information is needed, except when it is connected or not. This differs from knowing whether it was connected or not, which can be done through the listener properties of the audio session.

thanks

+6
iphone bluetooth
source share
2 answers

Call this method to find out if a Bluetooth headset is connected.

First import this #import <AVFoundation/AVFoundation.h>

 - (BOOL) isBluetoothHeadsetConnected { AVAudioSession *session = [AVAudioSession sharedInstance]; AVAudioSessionRouteDescription *routeDescription = [session currentRoute]; NSLog(@"Current Routes : %@", routeDescription); if (routeDescription) { NSArray *outputs = [routeDescription outputs]; if (outputs && [outputs count] > 0) { AVAudioSessionPortDescription *portDescription = [outputs objectAtIndex:0]; NSString *portType = [portDescription portType]; NSLog(@"dataSourceName : %@", portType); if (portType && [portType isEqualToString:@"BluetoothA2DPOutput"]) { return YES; } } } return NO; } 
+2
source share

Have you looked at: kAudioSessionProperty_AudioRoute ?

Also see this post:

How do I know if an external headset is connected to the iPhone?

+1
source share

All Articles