Skip to content

Commit

Permalink
For mozilla-mobile#15310: Also catch ActivityNotFoundException when s…
Browse files Browse the repository at this point in the history
…haring to app.
  • Loading branch information
mcarare committed Sep 28, 2020
1 parent fc06fdb commit 6289da8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/src/main/java/org/mozilla/fenix/share/ShareController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.mozilla.fenix.share

import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_SEND
Expand Down Expand Up @@ -98,13 +99,19 @@ class DefaultShareController(
setClassName(app.packageName, app.activityName)
}

@Suppress("TooGenericExceptionCaught")
val result = try {
context.startActivity(intent)
ShareController.Result.SUCCESS
} catch (e: SecurityException) {
snackbar.setText(context.getString(R.string.share_error_snackbar))
snackbar.show()
ShareController.Result.SHARE_ERROR
} catch (e: Exception) {
when (e) {
is SecurityException, is ActivityNotFoundException -> {
snackbar.setText(context.getString(R.string.share_error_snackbar))
snackbar.show()
ShareController.Result.SHARE_ERROR
}
else -> throw e
}
}
dismiss(result)
}
Expand Down

0 comments on commit 6289da8

Please sign in to comment.