我正在尝试实现android.bluetooth.le.ScanCallback,这是一个使用pyjnius的抽象类。当我实例化下面给定的python类时,出现了一个JVM错误。该错误指出android.bluetooth.le.ScanCallback不是接口类。我相信接口是一个抽象的类。我遗漏了什么?
class ScanCallback(PythonJavaClass):
__javainterfaces__ = ['android/bluetooth/le/ScanCallback']
def __init__(self, scanCallback, batchCallback=None, errorCallback=None):
super(ScanCallback, self).__init__()
self.batchCallbk = batchCallback
self.scanCallbk = scanCallback
self.errorCallbk = errorCallback
pass
@java_method ('(L/java/utils/List<ScanResult>/)V')
def onBatchScanResults(self,results):
print dir(results)
@java_method ('(I)V')
def onScanFailed(self, errorCode):
print "failed to scan" + str(errorCode)
raise ValueError(str(errorCode))
@java_method ('(IL/android/bluetooth/le/ScanResult)V')
def onScanResult(self, callbackType, result):
print dir(result)发布于 2016-11-03 14:33:42
我发现使用PyJNius只能实现接口类(纯抽象类),而不能实现抽象类。"android/ bluetooth /le/ScanCallback“是一个抽象类,而不是一个接口类,这是早期蓝牙API (< 21)的情况。
https://stackoverflow.com/questions/40112401
复制相似问题