17 |
Context cntx; |
Context cntx; |
18 |
Handler hndl; |
Handler hndl; |
19 |
|
|
20 |
|
Location lastKnownLocation = null; |
21 |
Location savedLocation = null; |
Location savedLocation = null; |
22 |
|
|
23 |
boolean isSearching = false; |
boolean isSearching = false; |
37 |
{ |
{ |
38 |
return savedLocation; |
return savedLocation; |
39 |
} |
} |
40 |
|
|
41 |
|
public Location getLastKnownLocation() { |
42 |
|
return lastKnownLocation; |
43 |
|
} |
44 |
|
|
45 |
public void locateStations() { |
public void locateStations() { |
46 |
|
|
57 |
if (provider.equalsIgnoreCase("gps")) |
if (provider.equalsIgnoreCase("gps")) |
58 |
hasGps = true; |
hasGps = true; |
59 |
locManager.requestLocationUpdates(provider, 0, 0, this); |
locManager.requestLocationUpdates(provider, 0, 0, this); |
60 |
|
|
61 |
|
saveLastKnownLocation(locManager.getLastKnownLocation(provider)); |
62 |
} |
} |
63 |
} else { |
} else { |
64 |
// message that no suitable provider was found |
// message that no suitable provider was found |
88 |
hndl.sendEmptyMessage(StationList.GOTLOCATION); |
hndl.sendEmptyMessage(StationList.GOTLOCATION); |
89 |
} |
} |
90 |
|
|
91 |
|
private void saveLastKnownLocation(Location loc) { |
92 |
|
if (lastKnownLocation == null) { |
93 |
|
lastKnownLocation = loc; |
94 |
|
} else { |
95 |
|
if (loc.getTime() > lastKnownLocation.getTime()) {//if loc is more recent than saved |
96 |
|
lastKnownLocation = loc; |
97 |
|
} |
98 |
|
} |
99 |
|
} |
100 |
|
|
101 |
public void stopSearch() |
public void stopSearch() |
102 |
{ |
{ |
103 |
if (isSearching) { |
if (isSearching) { |