3

On Lollipop 5.1.1 on a Nexus 4, and on Marshmallow 6.0.1 on the emulator, the TimePickerDialog comes up in my application looking like this:

However, on a Samsung S6 Edge running Marshmallow 6.0.1, it comes up like this:

completely blank.

The TimePickerDialog is initialised like this:

Calendar calendar = Calendar.getInstance();
Dialog timeDialog = new TimePickerDialog(androidContext, this, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true);
timeDialog.setTitle("Set Appointment Time");
timeDialog.show();
Floern
  • 33,559
  • 24
  • 104
  • 119
uvdevops
  • 93
  • 8

1 Answers1

4

I don't know why this is happening but I have worked around this issue by using the solution provided by cirit here. He's solving a different problem but it addresses this issue too.

The solution provided by cirit is to put a TimePicker widget into an AlertDialog. My implementation of his/her solution looks like this:

private void showTimePicker() {

    // This is implemented using an AlertDialog and a TimePicker instead of a TimePickerDialog
    // because the TimePickerDialog implementation on Samsung does not work.
    final Calendar c = Calendar.getInstance();
    c.setTimeInMillis(getInternalTimestamp());

    final TimePicker timePicker = new TimePicker(mContext);
    timePicker.setIs24HourView(DateFormat.is24HourFormat(mContext));
    timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(c.get(Calendar.MINUTE));

    final AlertDialog timePickerDialog = new AlertDialog.Builder(mContext)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // user clicked OK - store the result, perhaps by using a callback:
                    // myCallback.onTimeSet(timePicker, timePicker.getHour(), timePicker.getMinute();
                }
            })
            .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            })
            .setView(timePicker).show();
}

Not beautiful, but it works (for me) and it's not as ugly as I feared.

Community
  • 1
  • 1
Anton Epp
  • 56
  • 4