0

In the onStart method of my Fragment, I set the onClickListener of a button to open a web browser

 letsGoButton.setOnClickListener {

        val phoneNumber = phoneEt.text.toString()
        val regionCode = codeCcp.mSelectedCountry?.regionCode
        val countryCode = codeCcp.mSelectedCountry?.phoneCountryCode


        var baseUrl = "dev"
        when (BuildConfig.FLAVOR) {
            "dev" -> baseUrl = "s-dev.test.aws.the8app.com/verification?"
            "qa" -> baseUrl = "s-qa.test.aws.the8app.com/verification?"
            "uat" -> baseUrl = "s-uat.test.aws.the8app.com/verification?"
            "prod" -> baseUrl = "s-uat.test.aws.the8app.com/verification?"
        }
        val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("${baseUrl}countryCode=${countryCode}&number=${phoneNumber}&regionCode=$regionCode"))
        activity?.startActivity(browserIntent)
    }

When I click the button, I get the above error whether I call activity?.startActivity(browserIntent) or the Fragment's own startActivity(browserIntent) method. What am I missing?

andrewedgar
  • 797
  • 1
  • 12
  • 46

0 Answers0