public void run() {
   try {
     if (!mSensingKitLib.isSensorSensing(SKSensorType.LOCATION)) {
       mSensingKitLib.startContinuousSensingWithSensor(SKSensorType.LOCATION); // Start sensing
     }
   } catch (SKException e) {
     e.printStackTrace();
   }
 }
 public SensingServerThread() {
   super();
   try {
     // Subscribe the sensor data listener for Location module
     mSensingKitLib.subscribeSensorDataListener(SKSensorType.LOCATION, this);
   } catch (SKException e) {
     e.printStackTrace();
   }
 }
 public void onCreate() {
   super.onCreate();
   try {
     mSensingKitLib = SensingKitLib.getSensingKitLib(this); // Get SensingKitLib
     if (!mSensingKitLib.isSensorRegistered(
         SKSensorType.LOCATION)) { // Check whether the sensor module is registered
       mSensingKitLib.registerSensor(SKSensorType.LOCATION); // Register Sensor Module: LOCATION
       System.out.println("Registered!");
     }
     currentLocationArrayList = new ArrayList<SKLocationData>();
   } catch (SKException e) {
     e.printStackTrace();
   }
 }
 // Return an arraylist that shows which sensor module types are registered.
 // TODO NO NEED?
 public ArrayList<SKSensorType> getRegisteredSensors() {
   try {
     for (SKSensorType t : SKSensorType.values()) {
       if (mSensingKitLib.isSensorRegistered(t)) {
         if (!registeredSensors.contains(t)) { // ** Is it working?
           registeredSensors.add(t);
         }
       } else {
         if (registeredSensors.contains(t)) {
           registeredSensors.remove(t);
         }
       }
     }
   } catch (SKException e) {
     e.printStackTrace();
   }
   return registeredSensors;
 }
 // Stop Sensing the location and close SensingKit
 public Location stopSensing() {
   SKLocationData lastData = null;
   try {
     if (mSensingKitLib.isSensorSensing(SKSensorType.LOCATION)) {
       mSensingKitLib.stopContinuousSensingWithSensor(SKSensorType.LOCATION);
     }
     if (currentLocationArrayList.size() > 0) { // avoid null pointer exception
       lastData = currentLocationArrayList.get(currentLocationArrayList.size() - 1);
       System.out.println(
           "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); // print out the last
       // data
       System.out.println("The last data : " + lastData.getDataInCSV());
       System.out.println("The size of data list : " + currentLocationArrayList.size());
       System.out.println(">>Latitude : " + lastData.getLocation().getLatitude());
       System.out.println(">>Longitude : " + lastData.getLocation().getLongitude());
       return lastData.getLocation();
     }
   } catch (SKException e) {
     e.printStackTrace();
   }
   return null;
 }