In my app, I can have web URL starting with "https://" or "http://" or URL with custom scheme starting with "custom://" or "testing://".
I tried using URLUtil.isValidUrl()
, but this returns true only if URL starts with http or https.
How can I validate the URL with custom scheme in android?
If i understand right, you just need to validate if the syntaxe is right, right ?
I did an sample here to validate URLs using Regex
val regex = "([A-Za-z]*:\\/\\/)?\\S*".toRegex()
fun isValidUrl(url: String): Boolean {
return regex.containsMatchIn(url)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.