blob: d14fca40841ff072d56cbbcf3b46e223d790e575 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.MapProviderFactory;
import cgeo.geocaching.sensors.GeoData;
import cgeo.geocaching.sensors.Sensors;
import cgeo.geocaching.utils.Log;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
class GoogleMapsDirectionApp extends AbstractPointNavigationApp {
protected GoogleMapsDirectionApp() {
super(getString(R.string.cache_menu_maps_directions), R.id.cache_app_google_maps_direction, null);
}
@Override
public boolean isInstalled() {
return MapProviderFactory.isGoogleMapsInstalled();
}
@Override
public void navigate(final Activity activity, final Geopoint coords) {
try {
final GeoData geo = Sensors.getInstance().currentGeo();
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://maps.google.com/maps?f=d&saddr="
+ geo.getCoords().getLatitude() + "," + geo.getCoords().getLongitude() + "&daddr="
+ coords.getLatitude() + "," + coords.getLongitude())));
} catch (final Exception e) {
Log.i("GoogleMapsDirectionApp: application not available.", e);
}
}
}
|