Understanding deprecated in Android

Nilesh Deokar
MindOrks
Published in
2 min readAug 14, 2017

Google releases new versions of android with a year cycle. In process of which developers write some more useful API, methods, classes which are powerful than existing one. So they encourage developers to use newly written API’s and depricate old methods.

What is deprecation ?

  • In Android deprecation usually means “We will continue to support this, but we think there are better solutions”.
  • Most of the time features are deprecated rather than immediately removed, to provide backward compatibility, and to give programmers time to bring affected code into compliance with the new standard.

Is it wrong to use Deprecated methods or classes ?

  • The main disadvantage is that the API might not be available in future versions, which will increase the cost of updating your application.
  • If the deprecated method is easy to replace, use the replacement. If it isn’t, it’s up to you to decide whether developing the “future-proof” way is worth the additional effort.

For example :

What happens if i continue using Deprecated methods?

  • Code would continue running as it is until method is removed from SDK. If you are using deprecated method then you must keep track of removed apis whenever you upgrade to newest SDK.
  • If you don’t want a change at all then check for the reason behind deprecation. If deprecation is because of performance issues then you might consider upgrading to newest methods.

Conclusion :

By researching why a method is deprecated I often learn interesting things about SDK and different ways of doing same thing. There is often a good reason behind deprecation which leads to better understanding of the Android SDK. So from a learning/growing perspective, it is also a worthwhile effort.

I learned about VibrationEffect class while looking at ‘deprecated’ tag on .vibrate() method. Here is my learning :

Tap the ❤ button if you found this article useful!

--

--

Nilesh Deokar
MindOrks

Android Associate | Geek-ish | Crypt0gr4phy | UX Enthu