I wrote the network related code in Kotlin, and I referred to the following page.

class UDPSocketActivity: AppCompatActivity () {
    private var udpSocket: UdpSocket?= null
    private var handler: Handler
    init {
        val outerClass= WeakReference (this)
        handler= MyHandler (outerClass)
    override fun onCreate (savedInstanceState: Bundle?) {
        super.onCreate (savedInstanceState)
        setContentView (R.layout.activity_main)
        udpSocket= UdpSocket (handler)
        udpSocket? .startUDPSocket ()
        button.setOnClickListener {
            udpSocket? .sendMessage (editText.text.toString ())
    //Declare the Handler as a static class.
    class MyHandler (private val outerClass: WeakReference <
MainActivity >
): Handler () {
        override fun handleMessage (msg: Message?) {
            outerClass.get ()? .tv_receive? .append (msg? .obj.toString () + "\ n")
    override fun onDestroy () {
        super.onDestroy ()
        udpSocket? .stopUDPSocket ()

outerClass.get ()? .tv_receive?There is a line that says, and that is the error.
tv_receiveWhat is it?
Will the error disappear if I import some library etc.?

  • Answer # 1

    I think it is a function called synthetics that was used in the past.

    Someone has a commentary on Qiita:

    tv_recieveGuessing from the name, for displaying received dataTextViewofUDPSocketActivityI think I'm preparing for it.