/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/StationLocator.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/StationLocator.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 251 by torben, Sun Aug 9 11:48:36 2009 UTC revision 252 by torben, Mon Aug 10 10:49:43 2009 UTC
# Line 153  public class StationLocator implements L Line 153  public class StationLocator implements L
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  }  }

Legend:
Removed from v.251  
changed lines
  Added in v.252

  ViewVC Help
Powered by ViewVC 1.1.20