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-13 00:22:31 +0200
commitc10a326b5862e3769851fe4349eaa5a18bd17d31 (patch)
tree2f079ce8748d073d011e7cd7e643cb0f3dfe13a1
parent95eddd7926f71c253fbc1ebf32629eb1d8ea6575 (diff)
downloadandroid_packages_apps_Gallery2-c10a326b5862e3769851fe4349eaa5a18bd17d31.tar.gz
android_packages_apps_Gallery2-c10a326b5862e3769851fe4349eaa5a18bd17d31.tar.bz2
android_packages_apps_Gallery2-c10a326b5862e3769851fe4349eaa5a18bd17d31.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: I2e2637626d9f81780f48625bef52e861180e002c 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 7b824275c..6a216cc7f 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -271,25 +271,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) {