我想寫的Android使用kivy的蟒蛇爲Android蟒蛇藍牙庫。我使用jnius模塊中的autoclass導入java類。這是很好的工作,到目前爲止,然而,當我調用函數fetchUuidsWithSdp(),並檢查ACTION_UUID意圖對取出UUID的,我得到一個錯誤的對象。我正在使用的代碼是:爲什麼安卓ACTION_UUID返回錯誤的對象
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()
所以我在亞行控制檯中看到以下打印出來:
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
這說明「fetchedUUIDs」的對象類型是「android.os.Parcelable 'ParcelUuid'列表中包含的列表。當我呼叫toString()我得到以下軌跡:
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'
在我的代碼中是否有任何錯誤?任何幫助是極大的讚賞。