List of usage examples for android.app TimePickerDialog setOnKeyListener
public void setOnKeyListener(@Nullable OnKeyListener onKeyListener)
From source file:com.simplaapliko.trips.presentation.fragment.SelectTimeDialog.java
@NonNull @Override/* w w w . j ava 2 s. co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final TimePickerDialog pickerDialog = new TimePickerDialog(getActivity(), this, mCalendar.get(Calendar.HOUR_OF_DAY), mCalendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(getActivity())); pickerDialog.setOnKeyListener((dialog, keyCode, event) -> { switch (keyCode) { case KeyEvent.KEYCODE_BACK: dialog.cancel(); dialog.dismiss(); return true; default: return false; } }); return pickerDialog; }