androidkotlinphone-state-listener

How support PhoneStateListener for APIs below 31?


I have discovered that the code of my application has been deprecated. I was using PhoneStateListener class but now I see that this decreasing for API 31 and that now we have to use TelephonyCallback class. Is there any chance that the PhoneStateListener class is completely eliminated and my App is unwreneless for API versions below 31? Is there a compatibility library as it happens for the LocalDateTime class? Or what extent should I take to solve this problem? It is important to declare that the use of this class is of vital importance for my application.


Solution

  • The simple answer is that deprecated doesn't mean the class/method/function is no longer usable, it's just that it's recommended you do not use it anymore. It may go away in the future, but it won't be immediate.

    That being said, you're going to want to move to the TelephonyCallback class sooner than later in case the PhoneStateListener class is removed.