java - Run PendingIntent in exact time -


Everyone

I have received this code snippet

  pending = Sign = pending Gate activity (context, 0, intent, 0); Alarm = (AlarmManager) context.getSystemService (Event .ALARM_SERVICE); Alarm.set (alarm manager .rc, system syntetime millise (+ run della, pending signal);  

I'm getting rid of System.currentTimeMillis () + runDelay, and just run variable dynamic intofunction, does anyone know what I should do?

PS I should have API 8 code

Thanks a lot.

one

class variables:

  Personal Time PictureDialog Time_Picker; Private calendar target;  

A class creator

  public YOurClassName () {last calendar c = Calendar.getInstance (); Mayer = C. Gate (Calendar: IEER); MMonth = c.get (calendar .mONTH); Mday = c.get (Calendar DAY_OF_MONTH); MHour = c.get (calendar.HOUR_OF_DAY); Mminute = c. Gate (cal. Mnuete); }  

inside OnCreate () or onActivityCreated ():

  time_picker = New TimePickerDialog (getActivity (), mTimeSetListener, MHour, mminute, false);  

Inside the class:

  Private TimePickerDialog.OnTimeSetListener mTimeSetListener = New TimePickerDialog.OnTimeSetListener () {// Receive callback when When the user sets // in "TimePickerDialog", then Dialog public zeros (TimePicture view, int hour, intestinal minute) on the timecaster {hour = hourOfDay; Minute = minutes; Calendar Calendar = Calendar. Just Instance (); Calendar calSet = (calendar) calNow.clone (); CalSet.set (calendar.HOUR_OF_DAY, hour); CalSet.set (Calendar minutes, minutes); CalSet.set (calendar. SECOND, 0); CalSet.set (calendar. MILLISECOND, 0); If (calSet.compareTo (calNow) & lt; = 0) {// Today the set time has passed, calculate tomorrow at calSet.add (calendar.DATE, 1); } TargetCal = calSet; }};  

Use targetCal in your code like this

  alarm.set (AlarmManager.RTC, targetCal.getTimeInMillis (), Pending_intent);  

I hope this will help you


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -