massaimara98
massaimara98

Reputation: 7459

how to do something at specific time for everyday in android

i want to check some url at 9:00 a.m everyday.But how can i do this? I did check some topic and article about AlarmManager and IntentService but i can't get together for my application , is there any example code or something ?Thank you..

Upvotes: 1

Views: 5133

Answers (1)

Naruto Uzumaki
Naruto Uzumaki

Reputation: 2087

Try this:

 /Create alarm manager

 AlarmManager mAlarmManger = (AlarmManager)getSystemService(Context.ALARM_SERVICE);

 //Create pending intent & register it to your alarm notifier class
 Intent intent = new Intent(this, AlarmReceiver_maandag_1e.class);
 intent.putExtra("uur", "1e"); // if you want
 PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);

 //set timer you want alarm to work (here I have set it to 9.00)
 Calendar calendar = Calendar.getInstance();
 calendar.set(Calendar.HOUR_OF_DAY, 9);
 calendar.set(Calendar.MINUTE, 0);
 calendar.set(Calendar.SECOND, 0);

 //set that timer as a RTC Wakeup to alarm manager object
 mAlarmManger .set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);

Upvotes: 2

Related Questions