Skip to content Skip to sidebar Skip to footer

Android Sensors And Thread

I want to create an application where my sensors get values in another thread while the main thread is still working. I tried with just another thread, but it didn't working. I tri

Solution 1:

You start a service from within an onCreate method. That method, as the service initialization, run on the main thread. It means the service cannot run its initialization at the same time as your onCreate is running (not to mention that logging 0-998 it very very fast - 80ms from your log).

Moreover, you are registering listeners. Those will be called even after your service started.

You cannot synchronize those 2 actions like that. (And there is not enough details as to why you need any synchronization at all to point you in the right direction)

Post a Comment for "Android Sensors And Thread"