我在 android.i 中设计了计划短信,使用 CountDownTimer
构造函数类设置短信发送计时器。分配了计时器的值,但即使我已经通过了计时器值和间隔值,我也无法开始倒计时。如果我使用对象手动启动构造函数,则会立即发送短信(不等待设置的时间)。我需要在到达设置的发送时间时发送短信。这是我的代码。感谢任何帮助。
new Mycounter(dif, 1000);
// My Counter timer code goes here
public class Mycounter extends CountDownTimer
{
String phoneNo = txtPhoneNo.getText().toString();
String message = txtMessage.getText().toString();
public Mycounter(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
// TODO Auto-generated constructor stub
}
@Override
public void onFinish() {
sendSMS(phoneNo, message);
// TODO Auto-generated method stub
}
@Override
public void onTick(long millisUntilFinished)
{
// TODO Auto-generated method stub
}
}
最佳答案
你在调用start()吗?
new Mycounter(dif, 1000).start()
否则你的计时器代码看起来不错。
添加一些日志。
关于java - 短信调度问题(Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6926314/