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; |
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); |