From ccd9c1b69f2c93cc8ea84177094b413b53112dd3 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Wed, 20 Oct 2021 16:01:35 +0200 Subject: Show a toast when VPN setting intent is not available instead crashing --- .../ui/java/de/blinkt/openvpn/fragments/GeneralSettings.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'main/src/ui/java/de') 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() -- cgit v1.2.3