[Android] License: Make sure a web browser is installed on the device else fallback on Webview

Diego Fernando Nieto git at videolan.org
Thu Jul 2 12:57:25 CEST 2020


vlc-android | branch: master | Diego Fernando Nieto <diegofn at me.com> | Mon Jun 29 11:53:14 2020 -0500| [ffba0877f01dc33cdc818a0fde50bc29dca87309] | committer: Nicolas Pomepuy

License: Make sure a web browser is installed on the device else fallback on Webview

> https://code.videolan.org/videolan/vlc-android/commit/ffba0877f01dc33cdc818a0fde50bc29dca87309
---

 .../src/main/java/org/videolan/television/ui/LicenceActivity.kt   | 8 +++++++-
 application/vlc-android/src/org/videolan/vlc/gui/AboutFragment.kt | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/LicenceActivity.kt b/application/television/src/main/java/org/videolan/television/ui/LicenceActivity.kt
index 2ca8731df..5ec6ad1df 100644
--- a/application/television/src/main/java/org/videolan/television/ui/LicenceActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/LicenceActivity.kt
@@ -1,6 +1,7 @@
 package org.videolan.television.ui
 
 import android.annotation.SuppressLint
+import android.content.ActivityNotFoundException
 import android.content.Intent
 import android.net.Uri
 import android.os.Bundle
@@ -42,7 +43,12 @@ class LicenceActivity : FragmentActivity() {
                     view.loadUrl(url)
                 } else {
                     val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
-                    startActivity(intent)
+                    try {
+                        startActivity(intent)
+                    } catch (e: ActivityNotFoundException) {
+                        view.loadUrl(url)
+                    }
+
                 }
                 return true
             }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/AboutFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/AboutFragment.kt
index 623b18f5f..c9251078d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AboutFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AboutFragment.kt
@@ -21,6 +21,7 @@
 package org.videolan.vlc.gui
 
 import android.annotation.SuppressLint
+import android.content.ActivityNotFoundException
 import android.content.Intent
 import android.content.res.Configuration
 import android.net.Uri
@@ -109,7 +110,12 @@ class AboutFragment : Fragment() {
                         view.loadUrl(url)
                     } else {
                         val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
-                        startActivity(intent)
+                        try {
+                            startActivity(intent)
+                        } catch (e: ActivityNotFoundException) {
+                            view.loadUrl(url)
+                        }
+
                     }
                     return true
                 }



More information about the Android mailing list