0

I'm new to Android development.

I'm making a qr code scanning application, I'm trying to filter the scan data and see if it's a link, but I don't know how to do this because I'm very new to kotlin. Does anyone have a solution for this question?

I want to filter the browsing data, if there is "https" in the scan result, I want to open the link on chrome automatically

egeKasal
  • 3
  • 2
  • Use `.contains` https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/contains.html – Ken Wolf Mar 02 '23 at 15:20
  • If there is or begins with "https"? Also there are many libraries that already do this for you, do you actually want to implement this yourself for learning? – m0skit0 Mar 02 '23 at 15:42

2 Answers2

0
  for (i in scanned_list.indices) {
       single_scanned_value = scanned_list[i]
       if (single_scanned_value.contains("https")){
           //open browser.
       }
       break;
    }

For open browser, follow this link: https://www.tutorialkart.com/kotlin-android/android-open-url-in-browser-activity/

0

up

val list = listOf("I'm happy", "https:are you happy?", "no one is")
list.first { item -> item.lowercase().contains("https") }.apply { 
        doSomething(this)
    }

for open link inside Chrome just follow the answer here -> How can I open a URL in Android's web browser from my application?

dlsync
  • 1
  • 1
  • the problem about filter tool is that the final list could contains a lot of values, and if I have well understood the problem, user want to open browser of the first link finded. – Paolino L Angeletti Mar 02 '23 at 16:30