:P :P :P

On Sep 26, 8:03 am, saex <elpablos...@gmail.com> wrote:
> Hi
>
> i need to put some listeners on a Thread (to optimize my app), then,
> the Thread should be executed one time, but it needs to continue
> alive, because the listeners have to be alive to listen for events.
>
> I tryed with this code, but this code gives me an EXCEPTION
> (java.lang.RuntimeException: Can't create handler inside thread that
> has not called Looper.prepare())
>
> new Thread()
> {
>    public void run()
>    {
>       sensorMan = (SensorManager)
> getSystemService(Context.SENSOR_SERVICE);
>                                    sensorMan.registerListener(SensorListener,
> sensorMan.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
> SensorManager.SENSOR_DELAY_UI);
>                                sensorMan.registerListener(SensorListener,
> sensorMan.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
> SensorManager.SENSOR_DELAY_UI);
>
>    }
>
> }.start();
>
> Then, i tryed adding Looper.prepare() and Looper.loop(), and it gives
> not exception, but it iterates, and i dont want to get the Thread
> iterating.
>
> How can i do a thread that only executes itself one time but continues
> alive?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to