summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-09-14 00:07:01 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-09-14 00:07:01 +0000
commit8557b1a88bbd7da97620f61600bab53360d33800 (patch)
treebe035321f7d144e49597688e6e89f2ecc9cea1aa
parent531187f39d9104748651f3fe44d20029c78710bb (diff)
parentc10a326b5862e3769851fe4349eaa5a18bd17d31 (diff)
downloadandroid_packages_apps_Gallery2-8557b1a88bbd7da97620f61600bab53360d33800.tar.gz
android_packages_apps_Gallery2-8557b1a88bbd7da97620f61600bab53360d33800.tar.bz2
android_packages_apps_Gallery2-8557b1a88bbd7da97620f61600bab53360d33800.zip
Merge "Gallery2: Fix showOnMap method" into cm-10.2
-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) {