【发布时间】:2014-11-14 18:34:54
【问题描述】:
在我的应用程序中,我需要将参数传递给 TimerTask 以供使用 Context。但我做不到。在下面的代码中GetSMSThread 类是subclass,需要从主类获取参数。
Timer smsThread = new Timer();
GetSMSThread getSMSThread = new GetSMSThread();
smsThread.scheduleAtFixedRate(getSMSThread, 0, 100000);
GetSMSThread子类:
public class GetSMSThread extends TimerTask {
@Override
public void run() {
}
}
【问题讨论】:
-
你可以在 MainClass 中声明你的 TimerTask 类本身
标签: android android-task