Java Code Examples for android.os.AsyncTask#cancel()
The following examples show how to use
android.os.AsyncTask#cancel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationPickerActivity.java From LocationPicker with MIT License | 6 votes |
private void getAddressByGeoCodingLatLng() { //Get string address by geo coding from lat long if (mLatitude != 0 && mLongitude != 0) { if (MapUtility.popupWindow != null && MapUtility.popupWindow.isShowing()) { MapUtility.hideProgress(); } Log.d(TAG, "getAddressByGeoCodingLatLng: START"); //Cancel previous tasks and launch this one for (AsyncTask prevTask : filterTaskList) { prevTask.cancel(true); } filterTaskList.clear(); GetAddressFromLatLng asyncTask = new GetAddressFromLatLng(); filterTaskList.add(asyncTask); asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mLatitude, mLongitude); } }
Example 2
Source File: SearchBookContentsActivity.java From weex with Apache License 2.0 | 5 votes |
@Override protected void onPause() { AsyncTask<?,?,?> oldTask = networkTask; if (oldTask != null) { oldTask.cancel(true); networkTask = null; } super.onPause(); }
Example 3
Source File: BaseBlurEngine.java From EtsyBlur with Apache License 2.0 | 5 votes |
@CallSuper @Override public void destroy() { for (AsyncTask asyncTask : asyncTasks) { asyncTask.cancel(true); } asyncTasks.clear(); }
Example 4
Source File: InactivityTimer.java From Android with MIT License | 5 votes |
private synchronized void cancel() { AsyncTask<?, ?, ?> task = inactivityTask; if (task != null) { task.cancel(true); inactivityTask = null; } }
Example 5
Source File: AppPickerActivity.java From zxingfragmentlib with Apache License 2.0 | 5 votes |
@Override protected void onPause() { AsyncTask<?,?,?> task = backgroundTask; if (task != null) { task.cancel(true); backgroundTask = null; } super.onPause(); }
Example 6
Source File: SearchBookContentsActivity.java From barcodescanner-lib-aar with MIT License | 5 votes |
@Override protected void onPause() { AsyncTask<?,?,?> oldTask = networkTask; if (oldTask != null) { oldTask.cancel(true); networkTask = null; } super.onPause(); }
Example 7
Source File: SearchBookContentsActivity.java From zxingfragmentlib with Apache License 2.0 | 5 votes |
@Override protected void onPause() { AsyncTask<?,?,?> oldTask = networkTask; if (oldTask != null) { oldTask.cancel(true); networkTask = null; } super.onPause(); }
Example 8
Source File: BaseActivity.java From Simpler with Apache License 2.0 | 5 votes |
/** * 如果任务未执行完毕,则取消任务 * * @param clazz Activity Class */ public void unregisterAsyncTask(Class<? extends BaseActivity> clazz) { ArrayList<AsyncTask> tasks = new ArrayList<>(mTasks.removeAll(clazz)); int size = tasks.size(); if (size > 0) { for (int i = 0; i < size; i++) { AsyncTask task = tasks.get(i); //you may call the cancel() method but if it is not handled in doInBackground() method if (task != null && task.getStatus() != AsyncTask.Status.FINISHED) { task.cancel(true); } } } }
Example 9
Source File: NetworkTaskManager.java From CineLog with GNU General Public License v3.0 | 5 votes |
void cancelTasks() { for (AsyncTask task : taskList) { task.cancel(true); } taskList.clear(); }
Example 10
Source File: SearchBookContentsActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void launchSearch() { String query = queryTextView.getText().toString(); if (query != null && !query.isEmpty()) { AsyncTask<?,?,?> oldTask = networkTask; if (oldTask != null) { oldTask.cancel(true); } networkTask = new NetworkTask(); networkTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query, isbn); headerView.setText(R.string.msg_sbc_searching_book); resultListView.setAdapter(null); queryTextView.setEnabled(false); queryButton.setEnabled(false); } }
Example 11
Source File: AppPickerActivity.java From ZXing-Standalone-library with Apache License 2.0 | 5 votes |
@Override protected void onPause() { AsyncTask<?,?,?> task = backgroundTask; if (task != null) { task.cancel(true); backgroundTask = null; } super.onPause(); }
Example 12
Source File: ManagedAsyncTask.java From commcare-android with Apache License 2.0 | 5 votes |
/** * Call cancel on all tasks and then wipe the living task list. */ public static void cancelTasks() { synchronized (livingTasks) { for (AsyncTask task : livingTasks) { task.cancel(true); } livingTasks.clear(); } }
Example 13
Source File: InactivityTimer.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
private synchronized void cancel() { AsyncTask<?,?,?> task = inactivityTask; if (task != null) { task.cancel(true); inactivityTask = null; } }
Example 14
Source File: InactivityTimer.java From appinventor-extensions with Apache License 2.0 | 5 votes |
private synchronized void cancel() { AsyncTask<?,?,?> task = inactivityTask; if (task != null) { task.cancel(true); inactivityTask = null; } }
Example 15
Source File: InactivityTimerAssist.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 取消计时任务 */ private synchronized void cancel() { AsyncTask<?, ?, ?> task = mInactivityTask; if (task != null) { task.cancel(true); // 重置为 null mInactivityTask = null; } }
Example 16
Source File: InactivityTimer.java From moVirt with Apache License 2.0 | 5 votes |
private synchronized void cancel() { AsyncTask<?, ?, ?> task = inactivityTask; if (task != null) { task.cancel(true); inactivityTask = null; } }
Example 17
Source File: InactivityTimer.java From zxingfragmentlib with Apache License 2.0 | 5 votes |
private synchronized void cancel() { AsyncTask<?,?,?> task = inactivityTask; if (task != null) { task.cancel(true); inactivityTask = null; } }
Example 18
Source File: LocationPickerActivity.java From LocationPicker with MIT License | 5 votes |
@Override protected void onDestroy() { super.onDestroy(); for (AsyncTask task : filterTaskList) { task.cancel(true); } }
Example 19
Source File: InactivityTimer.java From AirFree-Client with GNU General Public License v3.0 | 5 votes |
private synchronized void cancel() { AsyncTask<?, ?, ?> task = inactivityTask; if (task != null) { task.cancel(true); inactivityTask = null; } }
Example 20
Source File: ListViewFragment.java From Header2ActionBar with Apache License 2.0 | 4 votes |
private void cancelAsyncTask(AsyncTask task) { if (task != null) task.cancel(false); }