summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2021-10-20 16:01:35 +0200
committerArne Schwabe <arne@rfc2549.org>2021-10-20 16:01:35 +0200
commitccd9c1b69f2c93cc8ea84177094b413b53112dd3 (patch)
tree03154f2575714bf30d28d9999b57f6b8f40f2b78
parent1e791c969df77a424d5d1561cd839aee5b6f00a0 (diff)
Show a toast when VPN setting intent is not available instead crashing
-rw-r--r--main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt11
1 files changed, 10 insertions, 1 deletions
diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt b/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt
index 811210d3..24734eb1 100644
--- a/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt
+++ b/main/src/ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt
@@ -5,6 +5,7 @@
package de.blinkt.openvpn.fragments
import android.app.Dialog
+import android.content.ActivityNotFoundException
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.ApplicationInfo
@@ -93,7 +94,15 @@ class GeneralSettings : PreferenceFragmentCompat(), Preference.OnPreferenceClick
)
builder.setMessage(R.string.use_alwayson_vpn)
builder.setNeutralButton(R.string.open_vpn_settings, { dialog, which ->
- startActivity(Intent(Settings.ACTION_VPN_SETTINGS))
+ try {
+ startActivity(Intent(Settings.ACTION_VPN_SETTINGS))
+ } catch (ane: ActivityNotFoundException) {
+ Toast.makeText(
+ requireContext(),
+ "Cannot launch VPN settings directly, please manually open the settings instead.",
+ Toast.LENGTH_SHORT
+ ).show()
+ }
})
builder.setPositiveButton(android.R.string.ok, null)
builder.show()