Kotlin Call Javascript function in Android without webView

Viewed 4229

Is there any way we can call JS function from Kotlin without having WebView in Android?

Let's say as mentioned below I have one JS function helloJS() in test.js file,

test.js:-

function helloJS(){
    return "Hello from JS"
}

And now I want to call this function from Kotlin file like

TestClass.kt:-

class TestHello{

    fun getHelloFromJS(){
        val name = test.helloJS()
    }
}

Till now I am using Webview and loading JS file into that and getting result as call back

But, I read that Kotlin is interoperable with JS like Java

So I am curious to know if there is any way we can use that on Android without having webView

4 Answers
Related