From 1a57c4c8136937dbb1482119e301e34f69abaf95 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Thu, 29 Apr 2021 00:22:13 +0900 Subject: [PATCH] Handle no map app. Fixes austinhuang0131/barinsta#1175 --- .../instagrabber/fragments/LocationFragment.java | 14 +++++++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java index 75690dd0..a1f14134 100644 --- a/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/LocationFragment.java @@ -1,5 +1,6 @@ package awais.instagrabber.fragments; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -461,9 +462,16 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR if (!locationModel.getGeo().startsWith("geo:0.0,0.0?z=17")) { locationDetailsBinding.btnMap.setVisibility(View.VISIBLE); locationDetailsBinding.btnMap.setOnClickListener(v -> { - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse(locationModel.getGeo())); - startActivity(intent); + try { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(locationModel.getGeo())); + startActivity(intent); + } catch (ActivityNotFoundException e) { + Toast.makeText(context, R.string.no_external_map_app, Toast.LENGTH_LONG).show(); + Log.e(TAG, "setupLocationDetails: ", e); + } catch (Exception e) { + Log.e(TAG, "setupLocationDetails: ", e); + } }); } else { locationDetailsBinding.btnMap.setVisibility(View.GONE); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 448086dc..b3f95e47 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -498,4 +498,5 @@ Top Recent Clear + No Map app found!