Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect wheather bluetooth headset is connected #540

Open
pluvias opened this issue May 26, 2020 · 0 comments
Open

Detect wheather bluetooth headset is connected #540

pluvias opened this issue May 26, 2020 · 0 comments

Comments

@pluvias
Copy link

pluvias commented May 26, 2020

Here is what I did after I found a Java solution. Doesn't work, there's something wrong in this code.
Does anyone know what I did wrong?

Thank you in advance


BluetoothAdapter = autoclass("android.bluetooth.BluetoothAdapter")
BluetoothProfile = autoclass("android.bluetooth.BluetoothProfile")

Adapter = BluetoothAdapter()
Profile = BluetoothProfile()

mAdapter = Adapter.getDefaultAdapter()
if (mAdapter != None and Profile.STATE_CONNECTED == mAdapter.getProfileConnectionState(Profile.HEADSET)):
    print ('connected')
else:
    print('disconnected') 



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant