/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/StationLocator.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/StationLocator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 237 by torben, Sat Aug 8 19:02:20 2009 UTC revision 238 by torben, Sat Aug 8 20:09:47 2009 UTC
# Line 10  import java.util.List; Line 10  import java.util.List;
10  import org.json.JSONArray;  import org.json.JSONArray;
11  import org.json.JSONObject;  import org.json.JSONObject;
12    
13    import dk.thoerup.traininfo.util.DownloadUtil;
14    
15  import android.content.Context;  import android.content.Context;
16  import android.location.Criteria;  import android.location.Criteria;
17  import android.location.Location;  import android.location.Location;
# Line 81  public class StationLocator implements L Line 83  public class StationLocator implements L
83                  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";
84                  //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";
85    
86                  try {                  try {/*
87                          Log.e("Url", urlSource);                          Log.e("Url", urlSource);
88                          URL url = new URL(urlSource);                          URL url = new URL(urlSource);
89                          URLConnection connection = url.openConnection();                          URLConnection connection = url.openConnection();
90                          connection.setConnectTimeout(5000);                          connection.setConnectTimeout(10000);
91    
92                          String line;                          String line;
93                          StringBuilder builder = new StringBuilder();                          StringBuilder builder = new StringBuilder();
94                          BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()), 8192);                          BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()), 8192);
95                          while((line = reader.readLine()) != null) {                          while((line = reader.readLine()) != null) {
96                                  builder.append(line);                                  builder.append(line);
97                          }                          }*/
98                            String data = DownloadUtil.getContent(urlSource, 30000, "UTF-8");
99                            StringBuilder builder = new StringBuilder(data);
100    
101                          while (builder.charAt(0) != '{')                          while (builder.charAt(0) != '{')
102                                  builder.deleteCharAt(0);                                  builder.deleteCharAt(0);

Legend:
Removed from v.237  
changed lines
  Added in v.238

  ViewVC Help
Powered by ViewVC 1.1.20