I have an activity with following code.
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// set time picker values
TimePicker picker = (TimePicker) findViewById(R.id.startTimePicker);
picker.setIs24HourView(true);
picker.setCurrentHour(10);
picker.setCurrentMinute(15);
}
So a time picker is set to a fixed time, this works as expected.
But when I rotate the screen and the activity get’s recreated the time picker show in all fields the same value – not the value set. This happens on one, two or more time pickers on screen.
Has anybody an explanation for this weird behaviour?
Apparently the issue is resolved when you put the time picker set calls in onResume().
This is really weird as onCreate gets also called on rotate and methods are hit,
but there must be some logic of the control itself called which causes that.
So here is the “fix”: