I launch TimePickerDialogFragment from a fragment. Everything works except when I set the time and press "Ok" button, callback to onDialogTimeSet( ) is not happening - after debugging I figured final Fragment fragment = getTargetFragment();' inTimePickerDialogFragment.javais returning null. Hence dismissing the dialog fragment without a call to -frag.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes());`
I tried setting a target fragment on my side of the code by calling .setTargetFragment(this) But has no impact. Could anyone see what is happening here?
final Activity activity = getActivity(); final Fragment fragment = getTargetFragment(); if (activity instanceof TimePickerDialogHandler) { final TimePickerDialogHandler act = (TimePickerDialogHandler) activity; act.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes()); } else if (fragment instanceof TimePickerDialogHandler) { final TimePickerDialogHandler frag = (TimePickerDialogHandler) fragment; frag.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes()); }
I launch TimePickerDialogFragment from a fragment. Everything works except when I set the time and press "Ok" button, callback to
onDialogTimeSet( )
is not happening - after debugging I figuredfinal Fragment fragment = getTargetFragment();' in
TimePickerDialogFragment.javais returning null. Hence dismissing the dialog fragment without a call to -
frag.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes());`I tried setting a target fragment on my side of the code by calling
.setTargetFragment(this)
But has no impact. Could anyone see what is happening here?final Activity activity = getActivity(); final Fragment fragment = getTargetFragment(); if (activity instanceof TimePickerDialogHandler) { final TimePickerDialogHandler act = (TimePickerDialogHandler) activity; act.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes()); } else if (fragment instanceof TimePickerDialogHandler) { final TimePickerDialogHandler frag = (TimePickerDialogHandler) fragment; frag.onDialogTimeSet(mReference, mPicker.getHours(), mPicker.getMinutes()); }