qpython icon indicating copy to clipboard operation
qpython copied to clipboard

java.lang.NullPointerException on most bluetooth calls

Open celiponcio opened this issue 7 years ago • 2 comments

Hello I tried around with bluetooth_chat.py. Got it working except for the return message. Boiled down the problem to the few lines seen in the attached file.

bluetooth_error_example.py.txt

There is another app that establishes connection, and this works and the bluetoothWrite call works. Then essentially it refuses to read or to stop with java.lang.NullPointerException error. But dir(droid) reports these methods to be present.

This is Qpython3 installed from google play on Android 4.2.2 (Samsung GT-S7580)

Would greatly appreciate any pointers on how to proceed.

celiponcio avatar Jan 17 '19 01:01 celiponcio

Well, to cut a long story short, this is the solution I found: https://github.com/kuri65536/python-for-android

celiponcio avatar Jan 21 '19 00:01 celiponcio

Hi, I have the same problem when I tried to receive message from bluetooth. Here is my code.

import androidhelper droid = androidhelper.Android() droid.toggleBluetoothState(True) cnRst = droid.bluetoothConnect() while True: message = droid.bluetoothReadLine().result print(message) droid.exit()

The error is same as yours. Could you teach me how to solve this error? Thank you so much.

JasonJunjieXu avatar Jul 23 '20 06:07 JasonJunjieXu