actual fun openUrlInBrowser(url: String) {
val intent = Intent(Intent.ACTION_VIEW).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
data = Uri.parse(url)
}
AppContext.get().startActivity(intent)
}
actual object AppContext {
private lateinit var application: Application
@Synchronized
fun init(context: Context) {
check(!::application.isInitialized) { "Application already initialized" }
application = context.applicationContext as Application
}
fun get(): Context {
if (::application.isInitialized.not()) throw Exception("Application context isn't initialized")
return application.applicationContext
}
}
Or you can easily just do this.
val uriHandler = LocalUriHandler.current
uriHandler.openUri("https://github.com/delacrixmorgan")