Also, while you are on the topic of Threads and Loopers, 99% of the time, if you think you need to create your own Looper instead of using one created by the system, your design has a mistake in it. Handler, HandlerThread and pre-existing Loopers should be enough. Even then AsyncTask is often easier and better.
On Sep 26, 8:30 am, Kostya Vasilyev <kmans...@gmail.com> wrote: > The exception is due to your thread not having a Looper, which a > fundamental low-level mechanism used by Android to delivers events to an > application. You can fix this, but.... > > You don't really need a thread for this - after you register a listener, > the main thread will continue to run, receiving event callbacks as needed. > > If your app is having performance problems, take a look at what you do > inside the listener callbacks and make it take less time. > > -- Kostya > > 26.09.2011 19:25, saex пишет: > > > It is for Augmented Reality App, i really need to use Threads for > > this, or the camera doesn't works properly > > > The code that i posted gives me an exception.... how can i avoid that > > exception? the Exception is posted in the question. > > > Thanks > > > On 26 sep, 16:52, TreKing<treking...@gmail.com> wrote: > >> On Mon, Sep 26, 2011 at 8:37 AM, saex<elpablos...@gmail.com> wrote: > >>> But i want to do it on a separate Thread, to optimize my app removing > >>> tasks > >>> from the main thread, because the main thread have a lot of tasks on it > >>> and > >>> it needs to use threads for such thinks > >> Putting arbitrary functionality on another thread will not optimize your > >> app > >> unless you make really good use of multi-core processers. In fact, it will > >> slow it down with the overhead of creating, switching to, running, and > >> cleaning up the thread. > > >>> please tell me how to make a thread that only executes itself one time > >> The code you already have will do exactly that, as pointless as it is. > > >> ------------------------------------------------------------------------------------------------- > >> TreKing<http://sites.google.com/site/rezmobileapps/treking> - Chicago > >> transit tracking app for Android-powered devices > > -- > Kostya Vasilyev -- 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