Search code examples
androidandroid-studiokotlintimer

How to disable depreciation in Android studio?


I try to use function formatNumberbut it's deprecated. How to disable depreciation? Or maybe use any alternative function?

enter image description here


Solution

  • Generally you should not disable the deprecation sign of a method. In most cases the given method's KDoc/Javadoc explains what should you use instead of the deprecated method.

    What does the deprecation means? (Offical Java docs)

    A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.

    Although you can disable the deprecation sign with an annotation at method signature level:

    @Suppress("DEPRECATION")
    fun methodName() {
       ...
       deprecatedMethod()
       ...
    }