15 |
|
|
16 |
List<StationBean> stations = new ArrayList<StationBean>(); |
List<StationBean> stations = new ArrayList<StationBean>(); |
17 |
|
|
18 |
|
public boolean lookupStations(String name) { |
19 |
|
return false; // Not supported |
20 |
|
} |
21 |
|
|
22 |
@Override |
@Override |
23 |
public void lookupStations(Location location) { |
public boolean lookupStations(Location location) { |
24 |
|
boolean success = false; |
25 |
//ToDo: to be nice put the api key into the request |
//ToDo: to be nice put the api key into the request |
26 |
String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=" + location.getLatitude() + "%2C" + location.getLongitude() + "&v=1.0"; |
String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=" + location.getLatitude() + "%2C" + location.getLongitude() + "&v=1.0"; |
27 |
//String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=56.2%2C9.0&v=1.0"; |
//String urlSource = "http://www.google.com/uds/GlocalSearch?callback=google.search.LocalSearch.RawCompletion&context=1&q=Train%20station&near=56.2%2C9.0&v=1.0"; |
28 |
|
|
29 |
try { |
try { |
30 |
String data = DownloadUtil.getContent(urlSource, 30000, "UTF-8"); |
String data = DownloadUtil.getContentString(urlSource, 30000); |
31 |
StringBuilder builder = new StringBuilder(data); |
StringBuilder builder = new StringBuilder(data); |
32 |
|
|
33 |
while (builder.charAt(0) != '{') |
while (builder.charAt(0) != '{') |
59 |
Log.e("Location", title + " " + lat +"," + lng); |
Log.e("Location", title + " " + lat +"," + lng); |
60 |
} |
} |
61 |
|
|
62 |
|
success = true; |
63 |
} catch (Exception e) { |
} catch (Exception e) { |
64 |
Log.e("Location","Location",e); |
Log.e("Location","Location",e); |
65 |
} |
} |
66 |
|
return success; |
67 |
} |
} |
68 |
|
|
69 |
@Override |
@Override |