blob: 1019b0f7be00170332fe5bcaa8cda9d04e28d8ac (
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
41
42
43
44
45
46
47
48
|
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.utils.Log;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
abstract class GoogleNavigationApp extends AbstractPointNavigationApp {
private final String mode;
protected GoogleNavigationApp(final int nameResourceId, final String mode) {
super(getString(nameResourceId), null);
this.mode = mode;
}
@Override
public boolean isInstalled() {
return true;
}
@Override
public void navigate(Activity activity, Geopoint coords) {
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("google.navigation:ll=" + coords.getLatitude() + ","
+ coords.getLongitude() + mode)));
} catch (Exception e) {
Log.i("GoogleNavigationApp.navigate: No navigation application available.", e);
}
}
static class GoogleNavigationWalkingApp extends GoogleNavigationApp {
GoogleNavigationWalkingApp() {
super(R.string.cache_menu_navigation_walk, "&mode=w");
}
}
static class GoogleNavigationDrivingApp extends GoogleNavigationApp {
GoogleNavigationDrivingApp() {
super(R.string.cache_menu_navigation_drive, "&mode=d");
}
}
}
|