Merge pull request #200 from TouchInstinct/fix/opening-browser

fix open browser
This commit is contained in:
rybakovi 2021-06-25 13:02:24 +03:00 committed by GitHub
commit 96d761a04d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -5,8 +5,11 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
fun Context.safeStartActivity(intent: Intent, options: Bundle? = null, resolveFlags: Int = 0): Boolean =
packageManager.resolveActivity(intent, resolveFlags)?.let { startActivity(intent, options) } != null
fun Context.safeStartActivity(intent: Intent, options: Bundle? = null, resolveFlags: Int = 0) =
try {
startActivity(intent, options)
} catch (e: Throwable) {
}
fun Context.openBrowser(url: String) = Intent(Intent.ACTION_VIEW)
.setData(Uri.parse(url))