Skip to content

Commit ab7695f

Browse files
committed
Avoid crashing on devices with no default browser
1 parent 25a2da3 commit ab7695f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/src/main/java/tech/httptoolkit/android/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,10 @@ private fun isPackageAvailable(context: Context, packageName: String) = try {
604604
false
605605
}
606606

607-
private fun getDefaultBrowserPackage(context: Context): String {
607+
private fun getDefaultBrowserPackage(context: Context): String? {
608608
val browserIntent = Intent("android.intent.action.VIEW", Uri.parse("http://example.com"))
609609
val resolveInfo = context.packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)
610-
return resolveInfo.activityInfo.packageName
610+
return resolveInfo?.activityInfo?.packageName
611611
}
612612

613613
private fun getTestBrowserPackage(context: Context): String? {

0 commit comments

Comments
 (0)