Skip to content

Commit

Permalink
Fix rare crashes when opening URLs
Browse files Browse the repository at this point in the history
We noticed that on rare occasions the IntentUtils.openUrl(..) method throws SecurityException on
Infinix devices. Let's ignore the exception for now and simply show a toast.
  • Loading branch information
Sergey-Makarov committed Dec 9, 2024
1 parent 736c42f commit a2baa2a
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ package com.fingerprintjs.android.playground.utils
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import androidx.core.content.FileProvider
import com.fingerprintjs.android.playground.BuildConfig
import com.fingerprintjs.android.playground.constants.Constants.DEVELOPERS_EMAIL
import java.io.File

object IntentUtils {
fun openUrl(activity: Activity, url: String) {
val uri = runCatching { Uri.parse(url) }.getOrNull() ?: return
val intent = Intent(Intent.ACTION_VIEW, uri)
activity.run {
if (intent.resolveActivity(packageManager) != null) {
startActivity(intent)
}
runCatching {
val uri = Uri.parse(url)!!
val intent = Intent(Intent.ACTION_VIEW, uri)
activity.startActivity(intent)
}.onFailure {
Toast.makeText(
activity,
"Error opening $url",
Toast.LENGTH_SHORT
).show()
}
}

Expand Down

0 comments on commit a2baa2a

Please sign in to comment.