Ich versuche, eine Python-Bluetooth-Bibliothek für Android mit Kivy Python für Android zu schreiben. Ich importiere Java-Klassen mit Autoclass von JNius-Modul. Es funktioniert soweit aber, wenn ich die Funktion fetchUuidsWithSdp() aufrufen und die ACTION_UUID-Intent für die abgerufenen UUIDs überprüfe, bekomme ich ein falsches Objekt. Der Code Ich verwende ist:Warum Android ACTION_UUID gibt falsches Objekt zurück
elif action == ACTION_UUID:
print("....... ACTION_UUID .......")
extras = intent.getExtras()
fetchedUUIDs = extras.get(EXTRA_UUID)
# fetchedUUIDs = intent.getParcelableArrayExtra(EXTRA_UUID)
print("fetchedUUIDs object type is: ..............")
print (fetchedUUIDs)
for u in fetchedUUIDs:
print u.toString()
, damit ich in der adb Konsole den folgenden Ausdruck:
I/python (30971): ....... ACTION_UUID .......
I/python (30971): fetchedUUIDs object type is: ..............
I/python (30971): [<android.os.Parcelable at 0x7c1f2600 jclass=android/os/Parcelable jself=<LocalRef obj=0x20f00dfa at 0x79f7bab0>>, <android.os.Parcelable at 0x7c1
, die den Objekttyp von ‚fetchedUUIDs‘ zeigt ist ‚android.os.Parcelable 'Liste der' ParcelUuid'-Liste nicht enthalten. Als ich toString() aufrufen ich die folgende Spur erhalten:
I/python (30971): Traceback (most recent call last):
I/python (30971): File "jnius/jnius_proxy.pxi", line 47, in jnius.jnius.PythonJavaClass.invoke (jnius/jnius.c:24931)
I/python (30971): File "jnius/jnius_proxy.pxi", line 73, in jnius.jnius.PythonJavaClass._invoke (jnius/jnius.c:25609)
I/python (30971): File "/home/tito/code/python-for-android/build/python-install/lib/python2.7/site-packages/android/broadcast.py", line 18, in onReceive
I/python (30971): File "main.py", line 235, in on_broadcast
I/python (30971): print u.toString()
I/python (30971): AttributeError: 'android.os.Parcelable' object has no attribute 'toString'
Gibt es irgend etwas falsch in meinem Code? jede Hilfe wird sehr geschätzt.