Reliable Method to perform web searches using intents

  android, kotlin

I’m working on an app that will on a fragment page, provide a list of charities to call should they be distressed, initial testing had been fine, then I began noticing that clicking the websites onCLickListeners sometimes wouldn’t work.

After a while, I realised that pressing the listener enough would eventually bring up the relevant site. Can anyone tell me how to make this more reliable?

As you can imagine, if you need to get some info then and there when distressed, having to click a link 3 times to bring up a website is poor.

Example of my code:

CharityPageFragment

    val char1Web = "gamcare.org.uk"
    binding.tvCharityOne.text = char1Name

    binding.tvCharityOneWebsite.setOnClickListener {
            webIntent(char1Web)
        }

private fun webIntent(website: String) {
        val intent = Intent(Intent.ACTION_WEB_SEARCH)
        intent.putExtra(SearchManager.QUERY, website)
        startActivity(intent)
    }

Source: Android Questions

LEAVE A COMMENT