當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncTask.cancel方法代碼示例

本文整理匯總了Java中android.os.AsyncTask.cancel方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncTask.cancel方法的具體用法?Java AsyncTask.cancel怎麽用?Java AsyncTask.cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.AsyncTask的用法示例。


在下文中一共展示了AsyncTask.cancel方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onStop

import android.os.AsyncTask; //導入方法依賴的package包/類
@Override
public void onStop() {
    // Cancel all the async tasks
    // please be aware that even after stopping, the async task continues until background task has finished
    for (AsyncTask task : new AsyncTask[] { mDetailRowBuilderTask, mBackdropTask, mVideoInfoTask, mFullScraperTagsTask,
            mSubtitleFilesListerTask, mPosterSaverTask, mBackdropSaverTask, mThumbnailAsyncTask}) {
        if (task!=null) {
            task.cancel(true);
        }
    }
    //do not update remote resume
    Log.d(TAG, "removeParseListener");
    XmlDb.getInstance().removeParseListener(mRemoteDbObserver);
    XmlDb.getInstance().removeResumeChangeListener(this);
    super.onStop();
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:17,代碼來源:VideoDetailsFragment.java

示例2: unregisterAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
/**
 * 如果任務未執行完畢,則取消任務
 *
 * @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);
            }
        }
    }
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:19,代碼來源:BaseActivity.java

示例3: cancel

import android.os.AsyncTask; //導入方法依賴的package包/類
private synchronized void cancel() {
    AsyncTask<?, ?, ?> task = inactivityTask;
    if (task != null) {
        task.cancel(true);
        inactivityTask = null;
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:8,代碼來源:InactivityTimer.java

示例4: cancel

import android.os.AsyncTask; //導入方法依賴的package包/類
private synchronized void cancel() {
  AsyncTask<?,?,?> task = inactivityTask;
  if (task != null) {
    task.cancel(true);
    inactivityTask = null;
  }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:8,代碼來源:InactivityTimer.java

示例5: clearAllTasks

import android.os.AsyncTask; //導入方法依賴的package包/類
@Override
public void clearAllTasks() {
    if(tasks == null)
        return;
    for (AsyncTask task : tasks) {
        try {
            if(task.getStatus() != AsyncTask.Status.FINISHED)
                task.cancel(true);
        }
        catch (Exception ignore){}
    }
    tasks.clear();
}
 
開發者ID:nyris,項目名稱:Nyris.IMX.Android,代碼行數:14,代碼來源:Nyris.java

示例6: cancel

import android.os.AsyncTask; //導入方法依賴的package包/類
private synchronized void cancel() {
	AsyncTask<?, ?, ?> task = inactivityTask;
	if (task != null) {
		task.cancel(true);
		inactivityTask = null;
	}
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:8,代碼來源:InactivityTimer.java

示例7: unsubscribeFromBackgroundTask

import android.os.AsyncTask; //導入方法依賴的package包/類
@Override
public void unsubscribeFromBackgroundTask(int taskId) {
    AsyncTask backgroundTask = backgroundTasks.remove(taskId);
    if (backgroundTask != null) {
        // Passing in "false" because the already running background task should not be interrupted.
        // If the task has completed or is marked as canceled we don't care, therefore the return value won't be checked.
        backgroundTask.cancel(false);
    }
}
 
開發者ID:BioID-GmbH,項目名稱:BWS-Android,代碼行數:10,代碼來源:AsynchronousBackgroundHandler.java

示例8: cancelAll

import android.os.AsyncTask; //導入方法依賴的package包/類
@Override
public void cancelAll() {
	final Iterator<TextView> textViewIterator = tasks.keySet().iterator();

	while (textViewIterator.hasNext()) {
		final AsyncTask existingTask = tasks.get(textViewIterator.next());

		if (existingTask != null) {
			existingTask.cancel(false);
			textViewIterator.remove();
		}
	}
}
 
開發者ID:MatthewTamlin,項目名稱:Mixtape,代碼行數:14,代碼來源:TitleBinder.java

示例9: onPause

import android.os.AsyncTask; //導入方法依賴的package包/類
@Override
protected void onPause() {
  AsyncTask<?,?,?> task = backgroundTask;
  if (task != null) {
    task.cancel(true);
    backgroundTask = null;
  }
  super.onPause();
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:10,代碼來源:AppPickerActivity.java

示例10: clearAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
protected void clearAsyncTask() {
	Iterator<AsyncTask<Void, Void, Boolean>> iterator = mAsyncTasks
			.iterator();
	while (iterator.hasNext()) {
		AsyncTask<Void, Void, Boolean> asyncTask = iterator.next();
		if (asyncTask != null && !asyncTask.isCancelled()) {
			asyncTask.cancel(true);
		}
	}
	mAsyncTasks.clear();
}
 
開發者ID:qizhenghao,項目名稱:HiBangClient,代碼行數:12,代碼來源:BaseFragment.java

示例11: cancel

import android.os.AsyncTask; //導入方法依賴的package包/類
@Override
public void cancel(final ImageView imageView) {
	final AsyncTask existingTask = tasks.get(imageView);

	if (existingTask != null) {
		existingTask.cancel(false);
		tasks.remove(imageView);
	}
}
 
開發者ID:MatthewTamlin,項目名稱:Mixtape,代碼行數:10,代碼來源:ArtworkBinder.java

示例12: cancel

import android.os.AsyncTask; //導入方法依賴的package包/類
synchronized void cancel() {
	AsyncTask<?, ?, ?> task = inactivityTask;
	if (task != null) {
		task.cancel(true);
		inactivityTask = null;
	}
}
 
開發者ID:AnyRTC,項目名稱:anyRTC-RTCP-Android,代碼行數:8,代碼來源:InactivityTimer.java

示例13: cancel

import android.os.AsyncTask; //導入方法依賴的package包/類
private synchronized  void cancel() {
  AsyncTask<?,?,?> task = inactivityTask;
  if (task != null) {
    task.cancel(true);
    inactivityTask = null;
  }
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:8,代碼來源:InactivityTimer.java

示例14: cancelTask

import android.os.AsyncTask; //導入方法依賴的package包/類
/**
 * Cancel an {@link AsyncTask}.
 *
 * @param mayInterruptIfRunning <tt>true</tt> if the thread executing this
 *        task should be interrupted; otherwise, in-progress tasks are allowed
 *        to complete.
 */
public static void cancelTask(AsyncTask<?, ?, ?> task, boolean mayInterruptIfRunning) {
    if (task != null && task.getStatus() != AsyncTask.Status.FINISHED) {
        task.cancel(mayInterruptIfRunning);
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:13,代碼來源:LatinIMEUtil.java


注:本文中的android.os.AsyncTask.cancel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。