Call the system's Datepickerdialog on the 4.2.2 version, and find that the system calls Ondateset () two times when the click is OK, and it needs to be filtered one time.
Calendar Mcalendar = Calendar.getinstance (); Mcalendar.add (calendar.day_of_year, 1); final Datepickerdialog DateDialog = New Datepickerdialog (This, new Datepickerdialog.ondatesetlistener () { Boolean mfired = false; public void Ondateset (final DatePicker view, final int year, final int monthofyear, final int dayofmonth) { log.i ("PEW PEW "," Double Fire Check "); if (mfired = = True) { log.i ("Pew Pew", "Double fire occured". Silently-ish returning "); return; } else { //first time mfired mfired = true; } Normal Date picking logic goes here} }, Mcalendar.get (Calendar.year), Mcalendar.get (Calendar.month), Mcalendar.get (calendar.day_of_month));d atedialog.show ();
References: https://code.google.com/p/android/issues/detail?id=64895
Android two times call Datepickerdialog.ondateset ()