Could someone show me what is wrong?
I try to use a Handler
post a Runnable
but it's not execute
var mHandler: Handler? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mHandler = Handler()
var runnable = Runnable {
Log.d("TEST", "++++ runable")
Log.d("TEST", "++++ come end")
}
Log.d("TEST", "++++ runnable" + runnable)
Log.d("TEST", "++++ handle" + mHandler)
mHandler!!.post { runnable }
}
This is output
09-21 00:56:04.067 4419-4419/? D/TEST: ++++ runnablecom.vpioneer.activity.MainActivity$onCreate$runnable$1@529b8fb4 09-21 00:56:04.067 4419-4419/? D/TEST: ++++ handleHandler (android.os.Handler) {529b8cb4}
lateinit var mHandler: Handler
since you are creating itonCreate
. Then you don't need to worry about the nullability concerns. – Axinomancy