jvmMain.com.bselzer.ktx.intent.browser.Browser.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of intent-jvm Show documentation
Show all versions of intent-jvm Show documentation
Based on Android intents.
The newest version!
package com.bselzer.ktx.intent.browser
import com.bselzer.ktx.intent.JvmIntent
import com.bselzer.ktx.logging.Logger
import java.awt.Desktop
import java.net.URI
internal actual class SystemBrowser actual constructor() : JvmIntent(), Browser {
override fun open(uri: String): Boolean {
return try {
val desktop = desktop ?: return false
if (!desktop.isSupported(Desktop.Action.BROWSE)) {
return false
}
desktop.browse(URI.create(uri))
true
} catch (ex: Exception) {
Logger.e(ex) { "Failed to open the uri $uri." }
false
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy