I have one DatePickerDialog where user chose his DOB(Date of Birthday) and now i would like to calculate remaining days of birthday?
private void setDateTimeField () {
final Calendar newCalendar = Calendar.getInstance();
mDatePickerDialog = new DatePickerDialog(AddBirthday.this, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
SuperActivityToast.create(AddBirthday.this, "Left days to birthday: ",
SuperToast.Duration.SHORT, Style.getStyle(Style.RED, SuperToast.Animations.FLYIN)).show();
// Intent intent = new Intent(AddBirthday.this, AlarmReceiver.class);
// PendingIntent pendingIntent = PendingIntent.getBroadcast(AddBirthday.this,
// 0 , intent, PendingIntent.FLAG_UPDATE_CURRENT);
// AlarmManager am = (AlarmManager) AddBirthday.this.getSystemService(AddBirthday.this.ALARM_SERVICE);
// am.setRepeating(AlarmManager.RTC_WAKEUP, newDate.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
mYear = c.get(Calendar.YEAR); mYear is type integer for storing current year
getAge = mYear - year;
if ( getAge == 0 || year >= 2016 ) {
SuperActivityToast.create(AddBirthday.this, "Invalid Date of Birthday!",
SuperToast.Duration.SHORT, Style.getStyle(Style.RED, SuperToast.Animations.FLYIN)).show();
} else {
addBirthdayDate.setText(dateFormatter.format(newDate.getTime()));
dateSelected = String.valueOf(dayOfMonth) + " /" + String.valueOf(monthOfYear + 1)
+ " /" + String.valueOf(year);
}
}
}, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
}
And then i would like if i could give a user some reccurence picker for setting how many time he want to get notification until birthday.