How to solve Handler() deprecated?

后端 未结 12 1753
眼角桃花
眼角桃花 2020-12-05 09:00

Could anyone know, how to fix the deprecated warning or any alternate solution for this.

Handler().postDelayed({
    context?.let {
        //code
    }
}, 30         


        
12条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 09:36

    The handler() etc code is generated by the Android Studio 4.0.1 when a Fullscreen Activity, for example, is created from scratch. I know that we are being encouraged to use Kotlin, which I do, but from time to time I use sample projects to get an idea going. It seems strange that we are chastised by AS when AS actually generates the code. It might be a useful academic activity to go through the errors and fix them but maybe AS could generate new clean code for us enthusiasts...

提交回复
热议问题