// Set location by setting the latitude, longitude and may be the altitude... String[] MockLoc = str.split(","); Location location = new Location(mocLocationProvider); Double lat = Double.valueOf(MockLoc[0]); location.setLatitude(lat); Double longi = Double.valueOf(MockLoc[1]); location.setLongitude(longi); Double alti = Double.valueOf(MockLoc[2]); location.setAltitude(alti);
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; }
Location mockLocation = new Location(mocLocationProvider); // a string mockLocation.setLatitude(location.getLatitude()); // double mockLocation.setLongitude(location.getLongitude()); mockLocation.setAltitude(location.getAltitude()); mockLocation.setTime(System.currentTimeMillis()); locationManager.setTestProviderLocation( mocLocationProvider, mockLocation);
public static Location create(String source, double latitude, double longitude, double altitude, float accuracy) { Location location = create(source, latitude, longitude, accuracy); location.setAltitude(altitude); return location; }
// Set location by setting the latitude, longitude and may be the altitude... String[] MockLoc = str.split(","); Location location = new Location(mocLocationProvider); Double lat = Double.valueOf(MockLoc[0]); location.setLatitude(lat); Double longi = Double.valueOf(MockLoc[1]); location.setLongitude(longi); Double alti = Double.valueOf(MockLoc[2]); location.setAltitude(alti);
Location mockLocation = new Location(mocLocationProvider); // a string mockLocation.setLatitude(location.getLatitude()); // double mockLocation.setLongitude(location.getLongitude()); mockLocation.setAltitude(location.getAltitude()); mockLocation.setTime(System.currentTimeMillis()); locationManager.setTestProviderLocation( mocLocationProvider, mockLocation);
locationManager.addTestProvider(mocLocationProvider, false, false, false, false, true, true, true, 0, 5); locationManager.setTestProviderEnabled(mocLocationProvider, true); Location mockLocation = new Location(mocLocationProvider); // a string mockLocation.setLatitude(location.getLatitude()); // double mockLocation.setLongitude(location.getLongitude()); mockLocation.setAltitude(location.getAltitude()); mockLocation.setTime(System.currentTimeMillis()); locationManager.setTestProviderLocation( mocLocationProvider, mockLocation); <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION">
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());
protected void _simulate(Location location) { if (!location.hasAccuracy()) { location.setAccuracy(accuracy); } if (!location.hasAltitude()) { location.setAltitude(0); } try { Method locationJellyBeanFixMethod = Location.class.getMethod("makeComplete"); if (locationJellyBeanFixMethod != null) { locationJellyBeanFixMethod.invoke(location); } } catch (IllegalAccessException ignored) { } catch (NoSuchMethodException ignored) { } catch (InvocationTargetException ignored) {} mLocationManager.setTestProviderLocation(locationProviderName, 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); }
@Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { String rawLatitude = FileUtils.readFromSDFolder("latitude"); String rawLongitude = FileUtils.readFromSDFolder("longitude"); if(rawLatitude.equals("-91") && rawLongitude.equals("-181")) return; float mLatitude = Float.valueOf(rawLatitude); float mLongitude = Float.valueOf(rawLongitude); Location fakedLocation = new Location(LocationManager.GPS_PROVIDER); Random acc = new Random(); Random alt = new Random(); fakedLocation.setAccuracy(acc.nextFloat() * 50); fakedLocation.setAltitude(alt.nextDouble() * 500); fakedLocation.setLatitude(mLatitude); fakedLocation.setLongitude(mLongitude); float accuracy = fakedLocation.getAccuracy(); double altitude = fakedLocation.getAltitude(); double longitude = fakedLocation.getLongitude(); double latitude = fakedLocation.getLatitude(); String provider = fakedLocation.getProvider(); //Logger.log("Acc: " + accuracy + "\nAltitude: " + altitude + "\nLongitude: " + longitude + "\nLatitude: " + latitude + "\nProvider: " + provider); param.setResult(fakedLocation); } });
public void setLocation(Location loc) { android.location.Location location = new android.location.Location(locationProvider); location.setLatitude(loc.getLatitude()); location.setLongitude(loc.getLongitude()); location.setAltitude(loc.getAltitude()); // set the time so it's not ignored! location.setTime(System.currentTimeMillis()); locManagerSupplier.get().setTestProviderLocation(locationProvider, location); }
/** * */ @Override public void onLocationChanged(Location location) { if(mPref.getExternalGpsSource().equals("2")) { return; } if ((location != null) && location.getProvider().equals(LocationManager.GPS_PROVIDER)) { updateTimeout(); // MSL from NMEA is more correct as its not corrected by LocationManager if(mPref.useNmeaAltitude()) { location.setAltitude(mAltitude); } /* * Called by GPS. Update everything driven by GPS. */ if(!mPref.isSimulationMode()) { mGpsCallback.locationCallback(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); }
public Location toLocation() { Location location = new Location("GeoJSON"); location.setLatitude(this.getLatitude()); location.setLongitude(this.getLongitude()); location.setAltitude(this.getAltitude()); return location; }
public void findLocation() { if (mLocationManager == null) return; // fallback for the case where GPS and network providers are disabled Location hardFix = new Location("reverseGeocoded"); // Frangart, Eppan, Bozen, Italy hardFix.setLatitude(46.480302); hardFix.setLongitude(11.296005); hardFix.setAltitude(300); try { requestBestLocationUpdates(); //temporary set the current location, until a good provider is found curLoc = mLocationManager.getLastKnownLocation(mLocationManager.getBestProvider(new Criteria(), true)); } catch (Exception ex2) { // ex2.printStackTrace(); curLoc = hardFix; } }
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; }
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; }
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; }
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; }