-1

I have a IntentService, Suppose I launch it today 27/12/2015.

I want it to wait for a specific date and time i.e 05/01/2016 08:54 AM, On this date and time i want it call a method to do something.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Shady Watson
  • 114
  • 6
  • well i did a bit of study on alarmManager i don't think i can achieve my goal with it, so now if i some how can make an algorithm that can find the total miliseconds between two dates and time, i can put that service to slee, well im a newbie here don't know much about android. – Shady Watson Dec 27 '15 at 02:10
  • try some android tutorials to get you used to the basics, then look at the date/time API documentation, that should get you started. – EkcenierK Dec 27 '15 at 09:54
  • Time api is deprecated now, Calendar c = Calendar.getInstance(); SimpleDateFormat date = new SimpleDateFormat("d:M:yy"); SimpleDateFormat time = new SimpleDateFormat("h:m"); SimpleDateFormat amPm = new SimpleDateFormat("a"); Time = time.format(c.getTime()); Date = date.format(c.getTime()); AmPm = amPm.format(c.getTime()); This is how i'm getting time date but the problem is how do i invoke it on a particular date. – Shady Watson Dec 27 '15 at 13:35

1 Answers1

2

SO i finally did it, posting the answer here for anyone who needs it, it is not the best way but its a way to get the job done the only solution i can came up with and stop voting down my question.

String userTime = textFiled1.getText().toString();
String userDate = textField2.getText().toString();

for(;;){
   Calendar c = Calendar.getInstance();

    SimpleDateFormat date = new SimpleDateFormat("d/M/yy");
    SimpleDateFormat time = new SimpleDateFormat("h:mm");

    Time = time.format(c.getTime());
    Date = date.format(c.getTime());


   if(userDate.equals(Date)){
       if(userTime.equals(Time)){
            // your code;

            break;
       }
   }
}
Shady Watson
  • 114
  • 6