From 7d898481a619ce2e5eace0fa897bf3ef90f3bb82 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Wed, 31 Mar 2021 19:45:31 +0800 Subject: [PATCH] fix autobug for devices that don't have URL sharing support --- .../java/com/geeksville/mesh/ui/ChannelFragment.kt | 14 ++++++++++++-- app/src/main/res/values/strings.xml | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt index 8caa6b9d..95f6de77 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt @@ -1,5 +1,6 @@ package com.geeksville.mesh.ui +import android.content.ActivityNotFoundException import android.content.Intent import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter @@ -143,8 +144,17 @@ class ChannelFragment : ScreenFragment("Channel"), Logging { type = "text/plain" } - val shareIntent = Intent.createChooser(sendIntent, null) - requireActivity().startActivity(shareIntent) + try { + val shareIntent = Intent.createChooser(sendIntent, null) + requireActivity().startActivity(shareIntent) + } + catch(ex: ActivityNotFoundException) { + Snackbar.make( + binding.shareButton, + R.string.no_app_found, + Snackbar.LENGTH_SHORT + ).show() + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8e2d4774..1e930b4a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -102,4 +102,5 @@ Are you sure you want to change to the default channel? Reset to defaults Apply + No application found to send URLs