how to link html with if else button in kotlin

41 Views Asked by At

I want to link button in my application with a website as when user click on this button the website open in browser, but i keep seeing ViewPostIme pointer 0 and ViewPostIme pointer 1 when i click the button. this my code:

val viewButton = findViewById<Button>(R.id.view_button)
        viewButton.setOnClickListener {
            val macAddress = scanResultBinding.deviceAddress.toString(){
            val url = if (macAddress.isNotEmpty() && macAddress == "//macAddress") {
                "MyWebsiteStore"
            } else {
                "MyWebsiteHome/"
            }
            val intent = Intent(Intent.ACTION_VIEW)
            intent.data = Uri.parse(url)
            startActivity(intent)
        }
   
0

There are 0 best solutions below