My problem is simple: because this method does not work for me when it's time is more than 30 minutes. I do not know exactly if it is for 30 but for 1 hour and 30 minutes it does not work. It just does not enter run () method of the Tempor class that inherits from TimerTask. But if I set it for seconds if it works.
public void TactivarBroucast(int a,int b) { //a y b el tiempo en horas (a) y el tiempo en minutos (b)
long t=b*3600000+a*60000; //1s = 1000ms 1m=60000
Log.d("metodo",String.valueOf(System.currentTimeMillis()+t));
Date date = new Date(System.currentTimeMillis()+t);
Calendar c = Calendar.getInstance();
c.setTime(date);
// c.set(Calendar.HOUR,b);
// c.set(Calendar.MILLISECOND,(int) t);
date = c.getTime();
Timer time = new Timer();
time.schedule(new Temporisador(), date);
}
The lines that are commented on is because I already tried and it did not work. I also understand that the AlarmManager can be used. How would the latter be? It should be noted that I am making an android application. How can I do to schedule a task on android to run after X time (hours and minutes)? Thanks in advance.