Skip to content

Commit 83e29ea

Browse files
authored
Merge pull request #3 from antoniohof/master
Add bluetooth headset detection
2 parents 2a30e79 + 872a054 commit 83e29ea

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Android/src/com/davikingcode/DetectHeadset/DetectHeadset.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public DetectHeadset(Context context) {
1313
}
1414

1515
public boolean _Detect() {
16-
17-
return myAudioManager.isWiredHeadsetOn();
16+
if(myAudioManager.isWiredHeadsetOn() || myAudioManager.isBluetoothA2dpOn()){
17+
return true;
18+
}else return false;
1819
}
1920
}

Assets/Plugins/iOS/DetectHeadset.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ bool _Detect() {
99
for (AVAudioSessionPortDescription* desc in [route outputs]) {
1010
if ([[desc portType] isEqualToString:AVAudioSessionPortHeadphones])
1111
return true;
12+
if ([[desc portType] isEqualToString:AVAudioSessionPortBluetoothHFP])
13+
return true;
1214
}
1315

1416
return false;

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ To use it, import the Plugins folder and inside your code call: `DetectHeadset.D
77

88
Note it will return **true** on *non supported platform*.
99

10-
For Android, you need to add a permission:
10+
For Android, you need to add permissions:
1111
`<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>`
12+
`<uses-permission android:name="android.permission.BLUETOOTH"/>`

0 commit comments

Comments
 (0)