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: A class creator inside OnCreate () or onActivityCreated (): Inside the class: Use I hope this will help you
Personal Time PictureDialog Time_Picker; Private calendar target;
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); }
time_picker = New TimePickerDialog (getActivity (), mTimeSetListener, MHour, mminute, false);
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; }};
targetCal
in your code like this
alarm.set (AlarmManager.RTC, targetCal.getTimeInMillis (), Pending_intent);
Comments
Post a Comment