summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2014-11-27 10:35:11 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2014-11-28 04:16:19 -0800
commitf6b2aac9b74b407c5cf1bfffbb578ed8efac358a (patch)
treeef6e5ba82256f96769fd70a31f852023558b0913 /src/com/android
parentf8e3352ea6759dd760f28017c4789a20731e2ee4 (diff)
downloadandroid_packages_apps_Gallery2-f6b2aac9b74b407c5cf1bfffbb578ed8efac358a.tar.gz
android_packages_apps_Gallery2-f6b2aac9b74b407c5cf1bfffbb578ed8efac358a.tar.bz2
android_packages_apps_Gallery2-f6b2aac9b74b407c5cf1bfffbb578ed8efac358a.zip
Gallery2: fix app crash when there is no map app
ActivityNotFoundException happened after click showOnMap menu when there is no map app. Catch the Exception to avoid app crash. CRs-Fixed: 753928 Change-Id: I7d811e4a636bed22935fcc050d97559ace44eb31
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index 8fb926c0b..8e4ebb714 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.util;
import android.annotation.TargetApi;
+import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
@@ -35,6 +36,7 @@ import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
+import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.app.GalleryActivity;
@@ -275,7 +277,7 @@ public class GalleryUtils {
return String.format(Locale.ENGLISH, format, latitude, longitude);
}
- public static void showOnMap(Context context, double latitude, double longitude) {
+ public static void showOnMap(final Context context, double latitude, double longitude) {
try {
// We don't use "geo:latitude,longitude" because it only centers
// the MapView to the specified location, but we need a marker
@@ -292,8 +294,21 @@ public class GalleryUtils {
// Use the "geo intent" if no GMM is installed
Log.e(TAG, "GMM activity not found!", e);
String url = formatLatitudeLongitude("geo:%f,%f", latitude, longitude);
- Intent mapsIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- context.startActivity(mapsIntent);
+ try {
+ Intent mapsIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ context.startActivity(mapsIntent);
+ } catch (ActivityNotFoundException ex) {
+ Log.e(TAG, "Map view activity not found! url = " + url, ex);
+ ((Activity)context).runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(context,
+ context.getString(R.string.map_activity_not_found_err),
+ Toast.LENGTH_SHORT).show();
+ }
+ });
+
+ }
}
}