¡@

Home 

2014/10/16 ¤W¤È 08:14:11

android Programming Glossary: getlooper

Best use of HandlerThread over other similar classes

http://stackoverflow.com/questions/18149964/best-use-of-handlerthread-over-other-similar-classes

extends HandlerThread Handler mHandler null CameraHandlerThread super CameraHandlerThread start mHandler new Handler getLooper synchronized void notifyCameraOpened notify void openCamera mHandler.post new Runnable @Override public void run oldOpenCamera..

How to create a Looper thread, then send it a message immediately?

http://stackoverflow.com/questions/4838207/how-to-create-a-looper-thread-then-send-it-a-message-immediately

to CommonsWare class Worker extends HandlerThread ... public synchronized void waitUntilReady d_handler new Handler getLooper d_messageHandler And from the main thread Worker worker new Worker worker.start worker.waitUntilReady ADDED worker.handler.sendMessage.. worker.waitUntilReady ADDED worker.handler.sendMessage ... This works thanks to the semantics of HandlerThread.getLooper which blocks until the looper has been initialized. Incidentally this is similar to my solution #1 above since the HandlerThread.. source public void run Looper.prepare synchronized this mLooper Looper.myLooper notifyAll Looper.loop public Looper getLooper synchronized this while mLooper null try wait catch InterruptedException e return mLooper The key difference is that..

Good way of getting the user's location in Android

http://stackoverflow.com/questions/6181704/good-way-of-getting-the-users-location-in-android

updateBestLocation location if getLocationQuality bestLocation LocationQuality.GOOD return We're done Looper l getLooper if l null l.quit public void onProviderEnabled String provider public void onProviderDisabled String provider public.. String provider int status Bundle extras TODO Auto generated method stub Log.i LocationCollector Fail Looper l getLooper if l null l.quit Register the listener with the Location Manager to receive location updates locationManager.requestLocationUpdates.. 1 locationListener Looper.myLooper Timer t new Timer t.schedule new TimerTask @Override public void run Looper l getLooper if l null l.quit Log.i LocationCollector Stopping collector due to timeout MAX_POLLING_TIME Looper.loop t.cancel locationManager.removeUpdates..