aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-15 21:39:37 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-15 21:39:37 +0100
commita83d85e5f0cbafe7291b8507c70dd3aac1a310ad (patch)
tree26d9137189521d96cdb281f226b6496266ba832f
parent875e1added3804a17437bdba69d74cddd5c20d4d (diff)
catch NPE on trying to start navigation if no app could be found
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
index d7e29e018..40ff08d80 100644
--- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java
@@ -2,6 +2,7 @@ package de.pixart.messenger.ui;
import android.Manifest;
import android.app.Activity;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -16,6 +17,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
+import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
@@ -87,8 +89,12 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback
case R.id.action_navigate:
double longitude = mLocation.longitude;
double latitude = mLocation.latitude;
- Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude)));
- startActivity(intent);
+ try {
+ Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:" + String.valueOf(latitude) + "," + String.valueOf(longitude)));
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(this, R.string.no_application_found_to_display_location, Toast.LENGTH_SHORT).show();
+ }
return true;
}
return super.onOptionsItemSelected(item);