I was using getRealMetrics() method and came to know that it is deprecated
val display = this.display
display?.getRealMetrics(outMetrics)
anybody know what is the alternative.
According to the official docs the recommended way is to use WindowManager#getCurrentWindowMetrics()
:
val metrics: WindowMetrics = context.getSystemService(WindowManager::class.java).currentWindowMetrics
If you use it to get screen size, please see my answer here.