summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-09-13 00:22:31 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-09-14 02:15:22 +0200
commit5ed2855a2bd82424a3fc49e6a08dd641f1dc5f09 (patch)
treeaa173d22eba42831c46f3465a5821690e75de070
parent189df6714508964e7453fddf0de702070041c542 (diff)
downloadandroid_packages_apps_Gallery2-5ed2855a2bd82424a3fc49e6a08dd641f1dc5f09.tar.gz
android_packages_apps_Gallery2-5ed2855a2bd82424a3fc49e6a08dd641f1dc5f09.tar.bz2
android_packages_apps_Gallery2-5ed2855a2bd82424a3fc49e6a08dd641f1dc5f09.zip
Gallery2: Fix showOnMap method
If the context is ProxyLauncher, showOnMap will make crash the Gallery app if GoogleMaps not exists, because the double call to startActivity. Just query the intent before call the startActivity method. Change-Id: I55472640e2073dc17a1e2c1630215328ae5effc7 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index c0db5e81a..5932c367a 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -276,25 +276,37 @@ public class GalleryUtils {
}
public static void showOnMap(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
- // for further operations (routing to/from).
- // The q=(lat, lng) syntax is suggested by geo-team.
- String uri = formatLatitudeLongitude("http://maps.google.com/maps?f=q&q=(%f,%f)",
- latitude, longitude);
- ComponentName compName = new ComponentName(MAPS_PACKAGE_NAME,
- MAPS_CLASS_NAME);
- Intent mapsIntent = new Intent(Intent.ACTION_VIEW,
- Uri.parse(uri)).setComponent(compName);
- context.startActivity(mapsIntent);
- } catch (ActivityNotFoundException e) {
- // 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);
+ // We use isIntentResolved here, because startActivity could derive in ProxyLauncher
+ // invocation, which makes an startActivity, and if the intent not exists we get a FC.
+
+ // 1.- GMM with MapView
+ // We don't use "geo:latitude,longitude" because it only centers
+ // the MapView to the specified location, but we need a marker
+ // for further operations (routing to/from).
+ // The q=(lat, lng) syntax is suggested by geo-team.
+ ComponentName gmmCompName = new ComponentName(MAPS_PACKAGE_NAME, MAPS_CLASS_NAME);
+ String gmmUri = formatLatitudeLongitude("http://maps.google.com/maps?f=q&q=(%f,%f)",
+ 0.0d, 0.0d);
+ Intent gmmIntent = new Intent();
+ gmmIntent.setComponent(gmmCompName);
+ gmmIntent.setData(Uri.parse(gmmUri));
+ gmmIntent.setAction(Intent.ACTION_VIEW);
+ if (isIntentResolved(context, gmmIntent)) {
+ context.startActivity(gmmIntent);
+ return;
}
+
+ // 2.- Geolocation content provider
+ Log.w(TAG, "GMM activity not found! Trying with geo scheme");
+ String geoUri = formatLatitudeLongitude("geo:%f,%f", 0.0d, 0.0d);
+ Intent geoIntent = new Intent();
+ geoIntent.setData(Uri.parse(geoUri));
+ geoIntent.setAction(Intent.ACTION_VIEW);
+ if (isIntentResolved(context, geoIntent)) {
+ context.startActivity(geoIntent);
+ }
+
+ // No maps. Why isGeolocationViewAvailable method not working?
}
public static boolean isGeolocationViewAvailable(Context context) {