Code example for HandlerThread

Methods: getLooperisAlivestart

			sensorEnabled = true;
			// create a new thread to run this sensor on 
			if (sensorHandlerThread == null)
				sensorHandlerThread = new HandlerThread("CameraLightSensor");
			// start the thread; 
			if (!sensorHandlerThread.isAlive())
			// 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)
						.post(updateAndSendValues = new UpdateAndSendCameraLightValues(0));
		} catch (Exception e) {
			Log.e(TAG, "Error in starting the Camera Light sensor: " + e.getMessage());
	public void stopLightSensing() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE