I understand that I'm a little late for the party, but seeing that this problem still exists, I believe that it deserves a real answer.
From what I read elsewhere, the problem is with individual fields of the TimePicker number having exactly the same identifier. The reason this problem is because when you rotate the screen, android closes all your dialogs, opens all your dialogs again using the typical onCreateDialog β onPrepareDialog, and then, most importantly, after you have done your dialogs, he returns and restores what was before. This means that no matter what you do in advance, the android will come in and break your TimePicker.
The answer, although not the most beautiful option, should appear after android and install it again.
Here is how I did it, I just made my own TimePicker:
public class MyTimePicker extends TimePicker { public MyTimePicker(Context context) { super(context); } public MyTimePicker(Context context, AttributeSet attrs) { super(context, attrs); } public MyTimePicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } private final static String B_MIN = "bMin"; private final static String B_HOUR = "bHour"; private final static String B_SUPER = "bSuper";
And yes, you need a handler. If you just run setCurrent commands from onRestoreInstanceState, android will just override you.
thepenguin77
source share