1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-11-23 19:36:16 -06:00

Fix opening twitter link from about on android 11 (#1460)

This commit is contained in:
Mikołaj Pich 2021-08-30 00:20:13 +02:00 committed by GitHub
parent d139c22782
commit d87283eb31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package io.github.wulkanowy.utils package io.github.wulkanowy.utils
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
@ -58,8 +59,11 @@ fun Context.getCompatBitmap(@DrawableRes drawableRes: Int, @ColorRes colorRes: I
fun Context.openInternetBrowser(uri: String, onActivityNotFound: (uri: String) -> Unit = {}) { fun Context.openInternetBrowser(uri: String, onActivityNotFound: (uri: String) -> Unit = {}) {
Intent.parseUri(uri, 0).let { Intent.parseUri(uri, 0).let {
if (it.resolveActivity(packageManager) != null) startActivity(it) try {
else onActivityNotFound(uri) startActivity(it)
} catch (e: ActivityNotFoundException) {
onActivityNotFound(uri)
}
} }
} }