You should ask yourself a few questions:
- Was it deprecated for the API levels that would execute this code?
- If so, is an alternative proposed or available?
In your case, getWidth() deprecated in favor of using getSize(Point) , which requires API level 13. Thus, up to API level 13, all you have is getWidth() , which at that time was not deprecated. The reason these legacy methods are supported is mainly due to backward compatibility (along with not breaking all applications that depend on it).
So, to answer your questions, yes, in this case itβs good, and yes, it is a good use of @SuppressWarning("deprecation") .
Jason robinson
source share