       (let [address  (str      (.getText (find-view activity ::address)))
             port     (Integer. (str (.getText (find-view activity ::port))))
             interval (Integer. (str (.getText (find-view activity ::interval))))]
-        (start-send address port interval sensorManager))
-      (stop-send sensorManager))))
+        (start-send address port interval))
+      (stop-send))))
 
 (defactivity com.illiichi.MyActivity
   :key :main
   :on-create
-  (fn [this bundle]    
+  (fn [this bundle]
+    (reset! sensorManager (.getSystemService (*a) Context/SENSOR_SERVICE))
     (on-ui
       (set-content-view! (*a)
         [:linear-layout {:orientation :vertical}

    [(create "rotate" Sensor/TYPE_ROTATION_VECTOR rotate-stack)
     (create "acc" Sensor/TYPE_LINEAR_ACCELERATION acc-stack)]))

(defn start-send [address port interval sensorManager]
  (for [stack [acc-stack rotate-stack]]
    (send stack (fn [_] [])))
  (reset! client (osc-client address port))
  (reset! listeners (create-listeners interval sensorManager))
  (prn "start"))

(defn stop-send [sensorManager]
  (map #(.unregisterListener sensorManager %) @listeners)
  (stop-and-reset-pool! my-pool)
  (reset! client nil)
  (reset! listeners nil)
  (prn "stop"))

(defn toggle-state [activity]
  (let [state (swap! state #(update-in % [:start?] not))
        sensorManager (.getSystemService activity Context/SENSOR_SERVICE)]
    (-> (find-views activity "button")
        (first)
        (.setText (if (:start? state)

                 (apply osc-send @client (str "/" id) (map mean coll)))
               [])]
    (every interval #(send-off stack task) my-pool)))

(defn push-vector [stack vals]
  (let [push (fn [xs xss]
               (prn (first (seq xs)))
               (if (empty? xss)
                 (map vector xs)
                 (map conj xss xs)))]
