List of usage examples for android.os Looper quit
public void quit()
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private static void removeAllCookiesV21() { final CookieManager cookieManager = CookieManager.getInstance(); Looper looper = Looper.myLooper(); boolean prepared = false; if (looper == null) { Looper.prepare();/*from w w w .j a v a2 s. c o m*/ prepared = true; } // requires a looper cookieManager.removeAllCookies(new ValueCallback<Boolean>() { @Override public void onReceiveValue(Boolean value) { Thread thread = new Thread() { @Override public void run() { // is synchronous, run in background cookieManager.flush(); } }; thread.start(); } }); if (prepared) { looper = Looper.myLooper(); if (looper != null) { looper.quit(); } } }
From source file:com.neogb.asynctaskfragment.WorkerFragment.java
@SuppressLint("NewApi") @Override//from w ww . j av a 2 s . c om public void onDestroy() { synchronized (mWorkerHandler) { mWorkerHandler.quit(); mWorkerHandler.setReady(false); mWorkerHandler.notify(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) { mWorkerHandlerThread.quit(); } else { Looper looper = mWorkerHandlerThread.getLooper(); if (looper != null) { looper.quit(); } } } super.onDestroy(); }
From source file:ch.luethi.skylinestracker.PositionService.java
@Override public void onDestroy() { locationManager.removeUpdates(this); skyLinesTrackingWriter = null;//from w w w .java 2 s .c om Looper looper = senderThread.getLooper(); if (looper != null) { looper.quit(); } stopSelf(); }
From source file:org.peterbaldwin.vlcremote.sweep.PortSweeper.java
public void destory() { abort(); Looper looper = mScanThread.getLooper(); looper.quit(); }
From source file:de.stadtrallye.rallyesoft.services.UploadService.java
private void quitLooperApi1(Looper looper) { looper.quit(); }
From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java
public void closeWorkerThread() { T.UI();//from www .j a v a 2 s . co m final Looper looper = mWorkerHandler.getLooper(); if (looper != null) looper.quit(); try { mWorkerThread.join(); } catch (InterruptedException e) { L.bug(e); } mWorkerHandler = null; mWorkerThread = null; T.resetRegistrationThreadId(); }
From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java
private void closeWorkerThread() { T.UI();/*from w ww . ja v a2 s.co m*/ final Looper looper = mWorkerHandler.getLooper(); if (looper != null) looper.quit(); try { mWorkerThread.join(); } catch (InterruptedException e) { L.bug(e); } mWorkerHandler = null; mWorkerThread = null; T.resetRegistrationThreadId(); }
From source file:applab.search.client.SynchronizationManager.java
/** * Called by our background or timer thread to perform the actual synchronization tasks from a separate thread. * /*from w ww .j a v a 2 s. c o m*/ * @throws XmlPullParserException */ private void performBackgroundSynchronization() throws XmlPullParserException { Boolean setupLooper = true; if (this.launchedFromTimer) { setupLooper = false; } if (setupLooper) { // we may want to associate UI with this task, so create // a looper to setup the message pump (by default, background threads // don't have a message pump) Looper.prepare(); } try { sendInternalMessage(GlobalConstants.KEYWORD_DOWNLOAD_STARTING); // We send this so that the dialog shows up // immediately SynchronizationManager.singleton.isSynchronizing = true; // First submit pending farmer registrations and get latest registration form String serverUrl = Settings.getServerUrl(); FarmerRegistrationController farmerRegController = new FarmerRegistrationController(); farmerRegController.postFarmerRegistrationData(serverUrl); farmerRegController.fetchAndStoreRegistrationForm(serverUrl); // Then submit pending usage logs and incomplete searches InboxAdapter inboxAdapter = new InboxAdapter(ApplabActivity.getGlobalContext()); inboxAdapter.open(); submitPendingUsageLogs(inboxAdapter); inboxAdapter.close(); // Finally update keywords updateKeywords(); } catch (Exception e) { e.printStackTrace(); completeSynchronization(); } if (setupLooper) { // TODO: Looper.loop is problematic here. This should be restructured Looper.loop(); Looper looper = Looper.getMainLooper(); looper.quit(); } }
From source file:com.mobicage.rpc.http.HttpCommunicator.java
public void close() { T.UI();/*from w w w. j av a 2 s . com*/ mMustFinish = true; // XXX: here we could be nicer e.g. wait 2 seconds for clean finish // e.g. synchronized(mFinishedLock) { try { mFinishedLock.wait(); } ... final Looper looper = mNetworkWorkerThread.getLooper(); if (looper != null) { looper.quit(); } if (mHttpPostRequest != null) mHttpPostRequest.abort(); try { // XXX: can this cause ANR? mNetworkWorkerThread.join(); } catch (InterruptedException e) { bugLog(e); } mNetworkHandler = null; mNetworkWorkerThread = null; final CountDownLatch latch = new CountDownLatch(1); mMainService.postAtFrontOfBIZZHandler(new SafeRunnable() { @Override public void safeRun() { T.BIZZ(); mBacklog.close(); latch.countDown(); } }); if (CloudConstants.USE_GCM_KICK_CHANNEL) { mMainService.unregisterReceiver(mBroadcastReceiver); } // XXX: can cause ANR try { latch.await(); } catch (InterruptedException e) { bugLog(e); } }
From source file:com.mobicage.rogerthat.MainService.java
private void destroyHttpWorkerThread() { T.UI();//from ww w . ja v a 2 s.c o m final Looper looper = mBizzWorkerThread.getLooper(); if (looper != null) looper.quit(); try { mBizzWorkerThread.join(); } catch (InterruptedException e) { L.bug(e); } mBizzHandler = null; mBizzWorkerThread = null; T.resetBizzThreadId(); }