首页 > 解决方案 > 输入参数传递给 Android 中的处理程序线程

问题描述

有人可以帮我如何将输入参数传递给 Handler 线程吗?顺序如下:

启动处理程序线程

fun startBMBConnectionThread(name: String, uuid: UUID) {
        // Start the thread to listen on a BluetoothServerSocket
        // Create and start the Handler thread.
        mBMBThread = BMBHandlerThread(name, uuid)
        mBMBThread?.start()
    }

处理程序线程内部类

private inner class BMBHandlerThread(inName: String, inUUID: UUID) : HandlerThread("name"){
   **// I am getting error in the below 2 lines**
    private val name = inName
    private val uuid = inUUID

    override fun onLooperPrepared() {
        super.onLooperPrepared()
        startBMBServerThread(name, uuid) //This will be the another Handler thread
    }
    // Handler will be added here

}

标签: androidandroid-handlerthread

解决方案


推荐阅读