Created
June 1, 2023 10:44
-
-
Save jack-webb/1170f75822514844005af693e914456b to your computer and use it in GitHub Desktop.
A better way to open a link in the user's browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val url = Uri.parse("https://www.asos.com/") | |
val browserSelectorIntent = Intent() | |
.setAction(Intent.ACTION_VIEW) | |
.addCategory(Intent.CATEGORY_BROWSABLE) | |
.setData(Uri.parse("http:")) | |
val targetIntent = Intent() | |
.setAction(Intent.ACTION_VIEW) | |
.addCategory(Intent.CATEGORY_BROWSABLE) | |
.setData(url) | |
targetIntent.selector = browserSelectorIntent | |
startActivity(targetIntent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment