Code example for HandlerThread

Methods: getLooper, isAlive, start

0
			sensorEnabled = true;
			// create a new thread to run this sensor on 
			if (sensorHandlerThread == null)
				sensorHandlerThread = new HandlerThread("CameraLightSensor");
			// start the thread; 
			if (!sensorHandlerThread.isAlive())
				sensorHandlerThread.start();
			// create a handler on the thread to run the update and send functions 
			if (cameraLightValueHandler == null)
				cameraLightValueHandler = new Handler(sensorHandlerThread.getLooper());
			// add the runnable 
			if (updateAndSendValues == null)
				cameraLightValueHandler
						.post(updateAndSendValues = new UpdateAndSendCameraLightValues(0));
		} catch (Exception e) {
			Log.e(TAG, "Error in starting the Camera Light sensor: " + e.getMessage());
		} 
	} 
 
	public void stopLightSensing() { 
		try {