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; |
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); |
String data = DownloadUtil.getContent(urlSource, 30000, "UTF-8"); |
88 |
URL url = new URL(urlSource); |
StringBuilder builder = new StringBuilder(data); |
|
URLConnection connection = url.openConnection(); |
|
|
connection.setConnectTimeout(5000); |
|
|
|
|
|
String line; |
|
|
StringBuilder builder = new StringBuilder(); |
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()), 8192); |
|
|
while((line = reader.readLine()) != null) { |
|
|
builder.append(line); |
|
|
} |
|
89 |
|
|
90 |
while (builder.charAt(0) != '{') |
while (builder.charAt(0) != '{') |
91 |
builder.deleteCharAt(0); |
builder.deleteCharAt(0); |