class LocationSerializer implements JsonSerializer<Location> { public JsonElement serialize(Location t, Type type, JsonSerializationContext jsc) { JsonObject jo = new JsonObject(); jo.addProperty("mProvider", t.getProvider()); jo.addProperty("mAccuracy", t.getAccuracy()); // etc for all the publicly available getters // for the information you're interested in // ... return jo; } } class LocationDeserializer implements JsonDeserializer<Location> { public Location deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException { JsonObject jo = je.getAsJsonObject(); Location l = new Location(jo.getAsJsonPrimitive("mProvider").getAsString()); l.setAccuracy(jo.getAsJsonPrimitive("mAccuracy").getAsFloat()); // etc, getting and setting all the data return l; } }
newLocation.setAccuracy(500);
public Location toSysLocation() { Location location = new Location(LocationManager.GPS_PROVIDER); location.setAccuracy(8f); Bundle extraBundle = new Bundle(); location.setBearing(bearing); Reflect.on(location).call("setIsFromMockProvider", false); location.setLatitude(latitude); location.setLongitude(longitude); location.setSpeed(speed); location.setTime(System.currentTimeMillis()); location.setExtras(extraBundle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(277000000); } int svCount = VirtualGPSSatalines.get().getSvCount(); extraBundle.putInt("satellites", svCount); extraBundle.putInt("satellitesvalue", svCount); return location; } }
private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }
@Override public void onMapLongClick(LatLng point) { if (mListener != null && !mPaused) { Location location = new Location("LongPressLocationProvider"); location.setLatitude(point.latitude); location.setLongitude(point.longitude); location.setAccuracy(100); mListener.onLocationChanged(location); } }
public Location createLocation(double lat, double lng, float accuracy) { // Create a new Location Location newLocation = new Location(PROVIDER); newLocation.setLatitude(lat); newLocation.setLongitude(lng); newLocation.setAccuracy(accuracy); return newLocation; }
Location loc = new Location(LocationManager.GPS_PROVIDER); loc.setLatitude(37.422); loc.setLongitude(-122.084); loc.setAltitude(0); loc.setTime(System.currentTimeMillis()); loc.setAccuracy(10); if (android.os.Build.VERSION.SDK_INT >= 17) loc.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
public Location create(String source, double latitude, double longitude, float accuracy) { Location location = new Location(source); location.setTime(System.currentTimeMillis()); location.setLatitude(latitude); location.setLongitude(longitude); location.setAccuracy(accuracy); return location; }
public Location createLocation(double lat, double lng, float accuracy) { // Create a new Location Location newLocation = new Location(LocationManager.GPS_PROVIDER); newLocation.setLatitude(lat); newLocation.setLongitude(lng); newLocation.setProvider(LocationManager.GPS_PROVIDER); newLocation.setAccuracy(1); newLocation.setTime(new Date().getTime()); newLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); return newLocation; }
public static Location create(String source, double latitude, double longitude, float accuracy) { Location location = create(source); location.setLatitude(latitude); location.setLongitude(longitude); location.setAccuracy(accuracy); return location; }
protected void _simulate(double longitude, double latitude, double altitude, int satellites) { Location mockLocation = new Location(locationProviderName); // a string mockLocation.setLatitude(latitude); // double mockLocation.setLongitude(longitude); mockLocation.setAltitude(altitude); if (satellites != -1) { Bundle bundle = new Bundle(); bundle.putInt("satellites", satellites); mockLocation.setExtras(bundle); } mockLocation.setTime(System.currentTimeMillis()); mockLocation.setAccuracy(accuracy); _simulate(mockLocation); }
public LocationProviderImpl(final Context ctx, final LocationService locationService) { mLocation = new Location("dummy"); mLocation.setProvider(getProviderName()); mLocation.setAccuracy(-1); locationService.registerProvider(this); }
@NonNull public Location getLocation() { Location l= new Location("waypoint"); l.setLatitude(getGeofenceLatitude()); l.setLongitude(getGeofenceLongitude()); l.setAccuracy(getGeofenceRadius()); return l; }
public static Location a(double d, double d2) { Location location = new Location("gps"); location.setLatitude(d); location.setLongitude(d2); location.setAccuracy(100.0f); location.setTime(System.currentTimeMillis()); if (VERSION.SDK_INT >= 17) { location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } return location; }
public static Location makeLocation(double latitude, double longitude) { Location location = new Location("gps"); location.setLatitude(latitude); location.setLongitude(longitude); location.setAccuracy(100.0F); location.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } return location; }
void pushLocation(double lat, double lon,double alt,float accuracy) { LocationManager lm = (LocationManager) ctx.getSystemService( Context.LOCATION_SERVICE); Location mockLocation = new Location(providerName); mockLocation.setLatitude(lat); mockLocation.setLongitude(lon); mockLocation.setAltitude(alt); mockLocation.setTime(System.currentTimeMillis()); mockLocation.setAccuracy(accuracy); if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } lm.setTestProviderLocation(providerName, mockLocation); }
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location l = new Location(LocationManager.GPS_PROVIDER); l.setLatitude(latitude); l.setLongitude(longtitude); l.setAccuracy(100f); l.setTime(0); /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); }*/ param.setResult(l); } });
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location l = new Location(LocationManager.GPS_PROVIDER); l.setLatitude(latitude); l.setLongitude(longtitude); l.setAccuracy(100f); l.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } param.setResult(l); } });
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location l = new Location(LocationManager.GPS_PROVIDER); l.setLatitude(latitude); l.setLongitude(longtitude); l.setAccuracy(100f); l.setTime(0); /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); }*/ param.setResult(l); } });
public android.location.Location toAndroidLocation() { android.location.Location location = new android.location.Location("wifi"); location.setLatitude(latitude()); location.setLongitude(longitude()); location.setAccuracy(radius()); return location; }