我在嘗試註冊SensorEventListener
但我的偵聽器類型錯誤。將類傳播到SensorEventListener
這裏是我的嘗試:
;; listener
(gen-class
:name com.spython.pushupcounter.main.sensor-listener
:implements [android.hardware.SensorEventListener]
:prefix "-"
:methods [[onAccuracyChanged [android.hardware.Sensor Integer] void]
[onSensorChanged [android.hardware.SensorEvent] void]])
(def listener com.spython.pushupcounter.main.sensor-listener)
(.registerListener sensor-manager listener proximitySensor 2)
看起來我需要投listener
到SensorEventListener
,對不對?
我該怎麼做?
你看到什麼錯誤?你可能需要添加一個[typehint](http://clojure.org/java_interop#Java%20Interop-Type%20Hints):'(.registerListener sensor-manager^SensorEventListener listener proximitySensor 2)' –