What's the reason that pushes android development team to deprecate some system methods, I know there are some methods that replaced with another methods which are more handful and helpful but some others not even replaced with another methods or are just replaced with one generalized big method which won't be helpful when trying to deal more specifically with some element, for example some methods from Date
class:
Date mDate = new Date();
mDate.getDate(); //Deprecated
mDate.getDay(); //Deprecated
mDate.getHours(); //Deprecated
mDate.getMinutes(); //Deprecated
mDate.getMonth(); //Deprecated
mDate.getSeconds(); //Deprecated
mDate.getYear(); //Deprecated
mDate.getTimezoneOffset(); //Deprecated
and the only one is exist now is :
mDate.getTime(); // gives the whole Time & Date as a `long` Value in milliseconds
now, when I get a Date Object
and try to get the Year , I have to:
- Declare a new
Calendar Object
. - makes it equal an instance of Calendar Class.
- sets this calendar object time to the date I got.
- extract the required attributes from this calendar object.
and what if that Data Object contains only the Date with the time equals to zero. now I have to make a workaround to save the time of the calendar before applying date to it, then reset the saved time to it again after applying date to it.
another example found here which illustrates that the entire PictureListener
interface is deprecated and There's no sign of what, if anything, is supposed to replace it.
third example when want to get screen width & height, that was direct:
int windowWidth, windowHeight;
windowWidth = getWindowManager().getDefaultDisplay().getWidth(); // Deprecated
windowHeight = getWindowManager().getDefaultDisplay().getHeight(); // Deprecated
but now:
int windowWidth, windowHeight;
DisplayMetrics metrices = new DisplayMetrics();
mContext.getWindowManager().getDefaultDisplay().getMetrics(metrices);
windowWidth = metrices.widthPixels;
windowHeight = metrices.heightPixels;