Catch more exceptions for startActivity
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package be.mygod.vpnhotspot.manage
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
@@ -45,21 +44,13 @@ object ManageBar : Manager() {
|
||||
fun start(context: Context) {
|
||||
try {
|
||||
context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_1))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
startAlternative(context, e)
|
||||
} catch (e: SecurityException) {
|
||||
startAlternative(context, e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startAlternative(context: Context, e: RuntimeException) {
|
||||
try {
|
||||
context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_2))
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message)))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message), Pair(SETTINGS_2, e.message)))
|
||||
} catch (e: SecurityException) {
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e.message), Pair(SETTINGS_2, e.message)))
|
||||
} catch (e1: RuntimeException) {
|
||||
try {
|
||||
context.startActivity(Intent().setClassName(SETTINGS_PACKAGE, SETTINGS_2))
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e1.message)))
|
||||
} catch (e2: RuntimeException) {
|
||||
DebugHelper.logEvent(TAG, bundleOf(Pair(SETTINGS_1, e1.message), Pair(SETTINGS_2, e2.message)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package be.mygod.vpnhotspot.manage
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
@@ -50,7 +49,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
manager.parent.startActivity(Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS,
|
||||
"package:${mainActivity.packageName}".toUri()))
|
||||
return
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
} catch (e: RuntimeException) {
|
||||
DebugHelper.logEvent("manage_write_settings", bundleOf(Pair("message", e.message)))
|
||||
}
|
||||
val started = manager.isStarted
|
||||
|
||||
@@ -14,6 +14,7 @@ import androidx.databinding.BindingAdapter
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.room.macToString
|
||||
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||
import java.lang.RuntimeException
|
||||
import java.net.InetAddress
|
||||
import java.net.NetworkInterface
|
||||
import java.net.SocketException
|
||||
@@ -79,7 +80,7 @@ fun Context.launchUrl(url: String) {
|
||||
if (app.hasTouch) try {
|
||||
app.customTabsIntent.launchUrl(this, url.toUri())
|
||||
return
|
||||
} catch (_: ActivityNotFoundException) { } catch (_: SecurityException) { }
|
||||
} catch (_: RuntimeException) { }
|
||||
SmartSnackbar.make(url).show()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user