153 |
// TODO Auto-generated method stub |
// TODO Auto-generated method stub |
154 |
|
|
155 |
} |
} |
156 |
|
|
157 |
public static void injectMockLocation(Context cntx) { |
public static void injectMockLocation(Context cntx) { |
158 |
Location loc = new Location("gps2"); |
Location odder = new Location("gps2"); |
159 |
loc.setLatitude(56.378084); |
odder.setLatitude(55.976632); |
160 |
loc.setLongitude(9.659815); |
odder.setLongitude(10.16407); |
161 |
|
|
162 |
|
Location kbh = new Location("gps2"); //Christiansborg 55.675092,12.578573 |
163 |
|
kbh.setLatitude(55.675092); |
164 |
|
kbh.setLongitude(12.578573); |
165 |
|
|
166 |
LocationManager lm = (LocationManager) cntx.getSystemService(Context.LOCATION_SERVICE); |
LocationManager lm = (LocationManager) cntx.getSystemService(Context.LOCATION_SERVICE); |
167 |
|
if (lm.getProvider("gps2") == null) |
168 |
|
lm.addTestProvider("gps2", false, true, true, false, false, false, false, 0, Criteria.ACCURACY_FINE ); |
169 |
lm.setTestProviderEnabled("gps2", true); |
lm.setTestProviderEnabled("gps2", true); |
170 |
lm.setTestProviderLocation("gps2", loc); |
lm.setTestProviderLocation("gps2", kbh); |
171 |
|
} |
172 |
|
|
173 |
|
public static void removeMockLocation(Context cntx) { |
174 |
|
LocationManager lm = (LocationManager) cntx.getSystemService(Context.LOCATION_SERVICE); |
175 |
|
if (lm.getProvider("gps2") != null) |
176 |
|
lm.removeTestProvider("gps2"); |
177 |
} |
} |
178 |
} |
} |