Is there any way to send SMS programmatically on scheduled time ? Without checking current time in every second.
Use the Android Timer class' schedule method to schedule the sms to be sent using something like the following in the run() method of the scheduled TimerTask:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
For a formatted date string, to get the when argument of the schedule() function, use the SimpleDateFormat class' parse() method. If your date string is "12/31/2013-12:12", then you can get the date object using:
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy-HH:mm");
Date when = sdf.parse(yourDateString, 0);
Other options for the SimpleDateFormat are here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With