SensorManager.registerListener (.., Handler handler), example please?

If I had to guess, it is so you can get your sensor events delivered on a background thread (e.g. , a HandlerThread ). By default, sensor events are delivered on the main application thread, which is fine in some cases.

If I had to guess, it is so you can get your sensor events delivered on a background thread (e.g. , a HandlerThread). By default, sensor events are delivered on the main application thread, which is fine in some cases.

Here you have an example: SensorManager mSensorMgr = (SensorManager) mContext. GetSystemService(Context. SENSOR_SERVICE); HandlerThread mHandlerThread = new HandlerThread("sensorThread"); mHandlerThread.start(); Handler handler = new Handler(mHandlerThread.getLooper()); mSensorMgr.

RegisterListener(this, mSensorMgr. GetDefaultSensor(Sensor. TYPE_ACCELEROMETER), SensorManager.

SENSOR_DELAY_FASTEST, handler); From the source code of android SensorManager's class you can see that the registerListener() extract the Looper of your Handler to create a new handler with this looper where it call the onSensorChanged method. If you don't pass your handler,the SensorManager will use the main application thread.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions