From 6b41f9de030408a353e71d9fe5b4af79726d630a Mon Sep 17 00:00:00 2001 From: Ermanno Baschiera Date: Tue, 19 Jan 2021 22:53:30 +0100 Subject: [PATCH] don't be that guy who lets an app to crash so badly --- .../com/ebaschiera/triplecamel/ShareActivity.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/ebaschiera/triplecamel/ShareActivity.java b/app/src/main/java/com/ebaschiera/triplecamel/ShareActivity.java index 3e0da11..e456a8d 100644 --- a/app/src/main/java/com/ebaschiera/triplecamel/ShareActivity.java +++ b/app/src/main/java/com/ebaschiera/triplecamel/ShareActivity.java @@ -1,6 +1,7 @@ package com.ebaschiera.triplecamel; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.os.Bundle; import android.content.Intent; import android.content.Context; @@ -52,7 +53,16 @@ protected void onCreate(Bundle savedInstanceState) { //Log.d("new_intent", camel_search_uri.toString()); Intent webIntent = new Intent(Intent.ACTION_VIEW, camel_search_uri); - startActivity(webIntent); + try { + startActivity(webIntent); + } catch (ActivityNotFoundException e) { + Context context = getApplicationContext(); + String text = getResources().getString(R.string.no_web_browser); + int duration = Toast.LENGTH_LONG; + Toast toast = Toast.makeText(context, text, duration); + toast.show(); + finish(); + } } else { //return a warning and stop the intent Context context = getApplicationContext();