当前位置: 首页>>代码示例>>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;未经允许,请勿转载。