How To Replace Old Getcurrenthour() With New Gethour()?
I have these code and work well to show time from timePicker. the code use getCurrentHour and getCurrentMinute. public void setTime(View view) { int hour = timePicker1.getCur
Solution 1:
You can check SDK version using android.os.Build.VERSION.SDK_INT
:
int hour = 0;
intmin = 0;
int currentApiVersion = android.os.Build.VERSION.SDK_INT;
if (currentApiVersion > android.os.Build.VERSION_CODES.LOLLIPOP_MR1){
hour = timePicker1.getHour();
min = timePicker1.getMinute();
} else {
hour = timePicker1.getCurrentHour();
min = timePicker1.getCurrentMinute();
}
Solution 2:
Ok, it works well with new time functions getMinute() and getHour() in emulator, So the problem probably cause because of API used. These tow functions require API 23.
Post a Comment for "How To Replace Old Getcurrenthour() With New Gethour()?"