I’m Creating a Alarm based Application with API version 23. But TimePicker getCurrentMinute,getCurrentHour method is Deprecated. Which method will be replace of this method ?
According to google documentation now we have to use getMinute() and getHour() method. But it's only working in api 23. what we have to do for other api?
Just check the Android official docs .. http://developer.android.com/reference/android/widget/TimePicker.html
it tells you everything
public Integer getCurrentMinute () Added in API level 1 This method was deprecated in API level 23. Use getMinute() Returns the current minute
public Integer getCurrentHour () Added in API level 1 This method was deprecated in API level 23. Use getHour() Returns the current hour in the range (0-23)
Android offers runtime checks for API version.
Most of the time in such cases, you’ll want to run cases like
if (Build.VERSION.SDK_INT >= 23 ) myTimePickerView.getHour(); else myTimePickerView.getCurrentHour();
i faced same issue. if you write your code such as
getCurrentHour()*(striked through) it doesnt make an issue
the code runs gets complied and runs saying
“complete build performed and run since…”
since if you use getHour or getMinute you have to put the version.SDK if else statement (which i tried but didnt work at that time for some reason)
and none the less increases code lines and complexity.