01.
class
GetLocation
extends
AsyncTask<Void, Void, String> {
02.
03.
private
DataView getLocation;
05.
06.
07.
public
GetLocation(DataView getLocation) {
08.
this
.getLocation = getLocation;
09.
}
10.
@Override
11.
protected
String doInBackground(Void... params) {
12.
try
{
13.
OkHttpClient okHttpClient =
new
OkHttpClient();
14.
Request.Builder builder =
new
Request.Builder();
15.
Request request = builder.url(urlJSON).build();
16.
com.squareup.okhttp.Response response = okHttpClient.newCall(request).execute();
17.
return
response.body().string();
18.
19.
}
catch
(Exception e) {
20.
Log.d(
"26novV1"
,
"e doIn==>"
+ e.toString());
21.
return
null
;
22.
}
23.
24.
}
25.
26.
@Override
27.
public
void
onPostExecute(String s) {
28.
29.
Log.d(
"26novV1"
,
"Json ==>"
+ s);
30.
31.
try
{
32.
33.
JSONArray jsonArray =
new
JSONArray(s);
34.
35.
double
max =
0
;
36.
double
min =
100
;
37.
38.
39.
for
(
int
i =
0
; i < jsonArray.length(); i +=
1
) {
40.
41.
JSONObject jsonObject = jsonArray.getJSONObject(i);
42.
43.
String strSignID = jsonObject.getString(
"SignID"
);
44.
String strSignName = jsonObject.getString(
"SignName"
);
45.
String strLat = jsonObject.getString(
"Latitude"
);
46.
String strLng = jsonObject.getString(
"Longitude"
);
47.
48.
double
[] LatArray =
new
double
[jsonArray.length()];
49.
LatArray[i] = Double.parseDouble(strLat);
50.
double
latt[] = {LatArray[i]};
51.
52.
double
[] LngArray =
new
double
[jsonArray.length()];
53.
LngArray[i] = Double.parseDouble(strLng);
54.
double
lngg[] = {LngArray[i]};
55.
56.
String[] signName =
new
String[jsonArray.length()];
57.
signName[i] = strSignName;
58.
String smm[] ={signName[i]};
59.
60.
sm[i] = strSignName;
61.
lat[i] = Double.parseDouble(strLat);
62.
lng[i] = Double.parseDouble(strLng);
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
Log.d(
"22FebV2"
,
"Name:"
+ places[i]+
"lat:"
+latitudes[i]+
"lng:"
+longitudes[i]);
74.
75.
}
76.
77.
78.
}
79.
catch
(Exception e) {
80.
e.printStackTrace();
81.
}
82.
83.
}
84.
}