73 |
if (hasGps) { |
if (hasGps) { |
74 |
if (!location.getProvider().equals("gps")) { |
if (!location.getProvider().equals("gps")) { |
75 |
return; // at least give the gps a chance |
return; // at least give the gps a chance |
76 |
} else if (location.getAccuracy() > 128) { |
} else if (location.getAccuracy() > 256) { |
77 |
return; //if we have a gps provider lets wait for a more precise fix |
return; //if we have a gps provider lets wait for a more precise fix |
78 |
} |
} |
79 |
|
|
106 |
// TODO Auto-generated method stub |
// TODO Auto-generated method stub |
107 |
|
|
108 |
} |
} |
|
|
|
|
|
|
|
public static void injectMockLocation(Context cntx) { |
|
|
Location odder = new Location("gps2"); |
|
|
odder.setLatitude(55.976632); |
|
|
odder.setLongitude(10.16407); |
|
|
|
|
|
Location kbh = new Location("gps2"); //Christiansborg 55.675092,12.578573 |
|
|
kbh.setLatitude(55.675092); |
|
|
kbh.setLongitude(12.578573); |
|
|
|
|
|
Location bjbro = new Location("gps2"); |
|
|
bjbro.setLatitude(56.380745); |
|
|
bjbro.setLongitude(9.655609); |
|
|
|
|
|
Location hillerod = new Location("gps"); |
|
|
hillerod.setLatitude(55.929177); |
|
|
hillerod.setLongitude(12.308095); |
|
|
|
|
|
Location aarhus = new Location("gps"); //Aros |
|
|
aarhus.setLatitude(56.153828); |
|
|
aarhus.setLongitude(10.200369); |
|
|
|
|
|
|
|
|
|
|
|
LocationManager lm = (LocationManager) cntx.getSystemService(Context.LOCATION_SERVICE); |
|
|
if (lm.getProvider("gps2") == null) |
|
|
lm.addTestProvider("gps2", false, true, true, false, false, false, false, 0, Criteria.ACCURACY_FINE ); |
|
|
lm.setTestProviderEnabled("gps2", true); |
|
|
lm.setTestProviderLocation("gps2", kbh); |
|
|
} |
|
|
|
|
|
public static void removeMockLocation(Context cntx) { |
|
|
LocationManager lm = (LocationManager) cntx.getSystemService(Context.LOCATION_SERVICE); |
|
|
if (lm.getProvider("gps2") != null) |
|
|
lm.removeTestProvider("gps2"); |
|
|
} |
|
109 |
} |
} |