Android的:如何在后台服务定期运行的AsyncTask [英] Android: how to run AsyncTask at regular interval in background service

查看:160
本文介绍了Android的:如何在后台服务定期运行的AsyncTask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何运行的AsyncTask 在在后台服务10次2分钟的睡眠周期定时?

How do I run an AsyncTask at regular interval of 2 mins sleep for 10 times in the background service?

作为VM在任何时间停止我的服务,我的的AsyncTask 也越来越封闭。

As VM stops my service at any time, my AsyncTask is also getting closed.

我曾尝试的ScheduledThreadPoolExecutor 定时的TimerTask 所有被暂时停止服务被停止。

I have tried ScheduledThreadPoolExecutor, Timer, TimerTask all gets stopped once Service gets stopped.

有一个很好的选择开始?

Is there a good option start with?

任何帮助是AP preciated。

Any help is appreciated.

推荐答案

你试过处理程序? ü可以阅读更多关于这此的链接

Have you tried the Handler? U can read more about this in this link

这篇关于Android的:如何在后台服务定期运行的AsyncTask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆