Alarm Manager

SheaduleAlarm using Alarm Manager


below alarm is set for it start from morning 9 O,click,
it repeat everny Half hour


public  void sheaduleAlarm(Context context)
{
   Calendar calendar = Calendar.getInstance();

   //set notification for date --> 8th January 2015 at 9:06:00 PM   calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
   calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
   calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH));

   calendar.set(Calendar.HOUR_OF_DAY, 9);
   calendar.set(Calendar.MINUTE, 0);
   calendar.set(Calendar.SECOND, 0);
   calendar.set(Calendar.AM_PM, Calendar.AM);

   Intent myIntent = new Intent(context, MyReceiver.class);
   pendingIntent = PendingIntent.getBroadcast(context, MyReceiver.REQUEST_CODE, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);

   AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
   alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_HALF_HOUR, pendingIntent);
}


get full demo here

https://drive.google.com/open?id=0B7De_mE7QNdOcHQ1Tml2SE02c28

No comments:

Post a Comment

Run/install/debug Android applications over Wi-Fi ?

Open Teminal/cmd --------------- Below steps is for Android 10 or lower Step 1 - Connect the device via USB and make sure debugging is work...