my question is about an how to rather than a question of coding problem.
I am tryn to send an sms after a certain amount of time if the activity is not closed. To explain it more, for example we have an app. To begin with in this app user can define a message and a number to send. Also user can define an alarm. And what the app does is this ; When the alarm starts to count and if the user doesnt respond the alarm in a certain amount of time ( e.g. if the user doesn't hit the close button in 10 minute ) the app will send the sms to the predefined number.
So how can i do this ? Thanks in advance.
Use cound Down timer and SMS manager. Basically when the count down timer ends send SMS in the onFinish() method. Please see the below pseudo-code. Hope this helps.
public class SMS {
public static void send_SMS(String number, Context context, String name) {
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, String);
} catch (Exception e) {
}
}
}
public class pauseTimer extends CountDownTimer {
public pauseTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
object.send_SMS(number,getApplicationContext, name)
}
}