How can I handle the problems with calling methods?

27 views Asked by At

I have problem with calling and running the methods. May be is referred to the one thing in logcat: A resource failed to close call. but this is a new error in my projects and I don`t have it before. here is my code below :

import android.os.Bundle
import androidx.activity.ComponentActivity

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
main4("456")
    }
    fun main4(ds:String):String{
        print(ds)
        return ds

    }
}

I need to print ds as you can see but it doesn`t show anything. thanks a lot for your attention.

1

There are 1 answers

0
Lino On

you can adjust the main4 function as follow:

fun main4(ds:String): String{
    println(ds)
    return ds
}

this way you can see the message in the standard output stream with

adb logcat -s "System.out"

03-03 08:44:11.789 16082 16082 I System.out: 456