Skip to content

AboutActivity crashes when no app handles mailto / external link #79

@jim-daf

Description

@jim-daf

AboutActivity.shouldOverrideUrlLoading (app/src/main/java/com/dozingcatsoftware/vectorcamera/AboutActivity.kt:44-50) routes any tapped link out of the About WebView via a fresh startActivity:

if (url.startsWith("mailto:")) {
    startActivity(Intent(Intent.ACTION_SENDTO, Uri.parse(url)))
    return true
}
if (url.startsWith("http:") || url.startsWith("https:")) {
    startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
    return true
}

If the device has no app that can handle the intent (no mail client for mailto:, no browser, stripped-down devices like automotive head units / kiosks / e-readers), startActivity raises ActivityNotFoundException, which is uncaught here and crashes the About screen mid-tap.

Suggested fix

Wrap both launches in a try { ... } catch (ActivityNotFoundException) { ... } and fall back to a short Toast so the About activity stays alive:

try {
    startActivity(intent)
} catch (e: ActivityNotFoundException) {
    Toast.makeText(this@AboutActivity, R.string.no_app_to_open_link, Toast.LENGTH_SHORT).show()
}

A PR with that change plus a no_app_to_open_link string is open at #80.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions