0

我有一个发送延迟文本的应用程序。我这样称呼它:

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
long delay = cal.getTimeInMillis();
smsControl.sendSMSLater(phoneNumber, msg, (date - delay));

剩下的就是:

class smsControl {

static ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);

public static void sendSMSLater(final String phoneNumber, final String msg, long date) {
    ScheduledFuture scheduledFuture = scheduledExecutorService.schedule(new Callable() {
        public Object call() throws Exception {
            SmsManager smsManager = SmsManager.getDefault();
            String smsNumber = phoneNumber;
            String smsText = msg;
            smsManager.sendTextMessage(smsNumber, null, smsText, null, null);
            return "Sent!";
        }
    }, date, TimeUnit.MILLISECONDS);

}

}

问题是它不等待延迟的时间日期。它在不久之后发送它。任何见解都有帮助!谢谢!

4

0 回答 0