Java Code Examples for android.location.Location#setBearing()
The following examples show how to use
android.location.Location#setBearing() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReplayRouteLocationConverter.java From graphhopper-navigation-android with MIT License | 6 votes |
List<Location> calculateMockLocations(List<Point> points) { List<Point> pointsToCopy = new ArrayList<>(points); List<Location> mockedLocations = new ArrayList<>(); for (Point point : points) { Location mockedLocation = createMockLocationFrom(point); if (pointsToCopy.size() >= 2) { double bearing = TurfMeasurement.bearing(point, points.get(1)); mockedLocation.setBearing((float) bearing); } time += delay * ONE_SECOND_IN_MILLISECONDS; mockedLocations.add(mockedLocation); pointsToCopy.remove(point); } return mockedLocations; }
Example 2
Source File: TrackStubUtils.java From mytracks with Apache License 2.0 | 6 votes |
/** * Creates a {@link MyTracksLocation} stub with specified values. * * @return a MyTracksLocation stub. */ public static MyTracksLocation createMyTracksLocation(double latitude, double longitude, double altitude) { // Initial Location Location loc = new Location(LOCATION_PROVIDER); loc.setLatitude(latitude); loc.setLongitude(longitude); loc.setAltitude(altitude); loc.setAccuracy(INITIAL_ACCURACY); loc.setSpeed(INITIAL_SPEED); loc.setTime(INITIAL_TIME); loc.setBearing(INITIAL_BEARING); SensorDataSet sd = SensorDataSet.newBuilder().build(); MyTracksLocation myTracksLocation = new MyTracksLocation(loc, sd); return myTracksLocation; }
Example 3
Source File: NmeaParser.java From contrib-drivers with Apache License 2.0 | 6 votes |
private void postLocation(long timestamp, double latitude, double longitude, double altitude, float speed, float bearing) { if (mGpsModuleCallback != null) { Location location = new Location(LocationManager.GPS_PROVIDER); // We cannot compute accuracy from NMEA data alone. // Assume that a valid fix has the quoted accuracy of the module. // Framework requires accuracy in DRMS. location.setAccuracy(mGpsAccuracy * 1.2f); location.setTime(timestamp); location.setLatitude(latitude); location.setLongitude(longitude); if (altitude != -1) { location.setAltitude(altitude); } if (speed != -1) { location.setSpeed(speed); } if (bearing != -1) { location.setBearing(bearing); } mGpsModuleCallback.onGpsLocationUpdate(location); } }
Example 4
Source File: BackgroundLocation.java From background-geolocation-android with Apache License 2.0 | 6 votes |
/** * Return android Location instance * * @return android.location.Location instance */ public Location getLocation() { Location l = new Location(provider); l.setLatitude(latitude); l.setLongitude(longitude); l.setTime(time); if (hasAccuracy) l.setAccuracy(accuracy); if (hasAltitude) l.setAltitude(altitude); if (hasSpeed) l.setSpeed(speed); if (hasBearing) l.setBearing(bearing); l.setExtras(extras); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(elapsedRealtimeNanos); } return l; }
Example 5
Source File: DebugViewTest.java From open with GNU General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { debugView = new DebugView(application); Location currentLocation = TestHelper.getTestLocation(40.660713, -73.989341); currentLocation.setBearing(130); currentLocation.setSpeed(milesPerHourToMetersPerSecond(30)); debugView.setCurrentLocation(currentLocation); Location snapLocation = TestHelper.getTestLocation(41.660713, -74.989341); snapLocation.setBearing(140); snapLocation.setSpeed(milesPerHourToMetersPerSecond(40)); debugView.setSnapLocation(snapLocation); Route route = new Route(TestHelper.MOCK_AROUND_THE_BLOCK); Instruction instruction = route.getRouteInstructions().get(0); debugView.setClosestInstruction(instruction); debugView.setClosestDistance(30); }
Example 6
Source File: LocationFactory.java From io.appium.settings with Apache License 2.0 | 6 votes |
public synchronized Location createLocation(String providerName, float accuracy) { Location l = new Location(providerName); l.setAccuracy(accuracy); l.setLatitude(latitude); l.setLongitude(longitude); l.setAltitude(altitude); l.setSpeed(0); l.setBearing(0); l.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } return l; }
Example 7
Source File: LocationUtil.java From VirtualLocation with Apache License 2.0 | 6 votes |
/** * GPS定位需要不停的刷新经纬度值 */ private static void setLocation(double latitude, double longitude) throws Exception{ try { String providerStr = LocationManager.GPS_PROVIDER; Location mockLocation = new Location(providerStr); mockLocation.setLatitude(latitude); mockLocation.setLongitude(longitude); mockLocation.setAltitude(0); // 高程(米) mockLocation.setBearing(0); // 方向(度) mockLocation.setSpeed(0); //速度(米/秒) mockLocation.setAccuracy(2); // 精度(米) mockLocation.setTime(System.currentTimeMillis()); // 本地时间 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { //api 16以上的需要加上这一句才能模拟定位 , 也就是targetSdkVersion > 16 mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } locationManager.setTestProviderLocation(providerStr, mockLocation); } catch (Exception e) { // 防止用户在软件运行过程中关闭模拟位置或选择其他应用 stopMockLocation(); throw e; } }
Example 8
Source File: BackgroundService.java From BackPackTrackII with GNU General Public License v3.0 | 6 votes |
public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jObject = (JsonObject) json; Location location = new Location(jObject.get("Provider").getAsString()); location.setTime(jObject.get("Time").getAsLong()); location.setLatitude(jObject.get("Latitude").getAsDouble()); location.setLongitude(jObject.get("Longitude").getAsDouble()); if (jObject.has("Altitude")) location.setAltitude(jObject.get("Altitude").getAsDouble()); if (jObject.has("Speed")) location.setSpeed(jObject.get("Speed").getAsFloat()); if (jObject.has("Bearing")) location.setBearing(jObject.get("Bearing").getAsFloat()); if (jObject.has("Accuracy")) location.setAccuracy(jObject.get("Accuracy").getAsFloat()); return location; }
Example 9
Source File: DataUploadServiceTest.java From open with GNU General Public License v3.0 | 6 votes |
@Test public void shouldHaveSpeedElement() throws Exception { String expectedSpeed = "40.0"; String groupId = "test-group-id"; String routeId = "test-route-id"; fillLocationsTable(groupId, routeId, 10, true); Location loc = getTestLocation(100, 200); loc.setBearing(4.0f); loc.setSpeed(Float.valueOf(expectedSpeed)); loc.setAccuracy(12f); loc.setAltitude(12f); loc.setTime(System.currentTimeMillis()); ContentValues insertValues = valuesForLocationCorrection(loc, loc, getTestInstruction(0, 0), routeId); db.insert(TABLE_LOCATIONS, null, insertValues); String actual = getTextForXpath(groupId, "//trk/trkseg/trkpt[position()=last()]/speed/text()"); assertThat(actual).isEqualTo(expectedSpeed); }
Example 10
Source File: SQLiteLocationDAOTest.java From background-geolocation-android with Apache License 2.0 | 5 votes |
@Test public void persistLocation() { Context ctx = InstrumentationRegistry.getTargetContext(); SQLiteDatabase db = new SQLiteOpenHelper(ctx).getWritableDatabase(); SQLiteLocationDAO dao = new SQLiteLocationDAO(db); Location location = new Location("fake"); location.setAccuracy(200); location.setAltitude(900); location.setBearing(2); location.setLatitude(40.21); location.setLongitude(23.45); location.setSpeed(20); location.setProvider("test"); location.setTime(1000); BackgroundLocation bgLocation = new BackgroundLocation(location); dao.persistLocation(bgLocation); ArrayList<BackgroundLocation> locations = new ArrayList(dao.getAllLocations()); Assert.assertEquals(1, locations.size()); BackgroundLocation storedLocation = locations.get(0); Assert.assertEquals(200, storedLocation.getAccuracy(), 0); Assert.assertEquals(900, storedLocation.getAltitude(), 0); Assert.assertEquals(2, storedLocation.getBearing(), 0); Assert.assertEquals(40.21, storedLocation.getLatitude(), 0); Assert.assertEquals(23.45, storedLocation.getLongitude(), 0); Assert.assertEquals(20, storedLocation.getSpeed(), 0); Assert.assertEquals("test", storedLocation.getProvider(), "test"); Assert.assertEquals(1000, storedLocation.getTime(), 0); Assert.assertFalse(storedLocation.hasMockLocationsEnabled()); Assert.assertFalse(storedLocation.areMockLocationsEnabled()); Assert.assertTrue(storedLocation.hasIsFromMockProvider()); // because setIsFromMockProvider is called in constructor Assert.assertFalse(storedLocation.isFromMockProvider()); }
Example 11
Source File: LocationProvider.java From open-location-code with Apache License 2.0 | 5 votes |
private void connectUsingOldApi() { Location lastKnownGpsLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); Location lastKnownNetworkLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); Location bestLastKnownLocation = mCurrentBestLocation; if (lastKnownGpsLocation != null && LocationUtil.isBetterLocation(lastKnownGpsLocation, bestLastKnownLocation)) { bestLastKnownLocation = lastKnownGpsLocation; } if (lastKnownNetworkLocation != null && LocationUtil.isBetterLocation( lastKnownNetworkLocation, bestLastKnownLocation)) { bestLastKnownLocation = lastKnownNetworkLocation; } mCurrentBestLocation = bestLastKnownLocation; if (mLocationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER) && mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mLocationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, FASTEST_INTERVAL_IN_MS, 0.0f, mGpsLocationListener); } if (mLocationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER) && mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { mLocationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, FASTEST_INTERVAL_IN_MS, 0.0f, mNetworkLocationListener); } if (bestLastKnownLocation != null) { Log.i(TAG, "Received last known location via old API: " + bestLastKnownLocation); if (mBearing != null) { bestLastKnownLocation.setBearing(mBearing); } mLocationCallback.handleNewLocation(bestLastKnownLocation); } }
Example 12
Source File: Utils.java From react-native-appmetrica with MIT License | 5 votes |
static Location toLocation(ReadableMap locationMap) { if (locationMap == null) { return null; } Location location = new Location("Custom"); if (locationMap.hasKey("latitude")) { location.setLatitude(locationMap.getDouble("latitude")); } if (locationMap.hasKey("longitude")) { location.setLongitude(locationMap.getDouble("longitude")); } if (locationMap.hasKey("altitude")) { location.setAltitude(locationMap.getDouble("altitude")); } if (locationMap.hasKey("accuracy")) { location.setAccuracy((float) locationMap.getDouble("accuracy")); } if (locationMap.hasKey("course")) { location.setBearing((float) locationMap.getDouble("course")); } if (locationMap.hasKey("speed")) { location.setSpeed((float) locationMap.getDouble("speed")); } if (locationMap.hasKey("timestamp")) { location.setTime((long) locationMap.getDouble("timestamp")); } return location; }
Example 13
Source File: TrackRecordingServiceTest.java From mytracks with Apache License 2.0 | 5 votes |
/** * Inserts a location and waits for 100ms. * * @param trackRecordingService the track recording service */ private void insertLocation(ITrackRecordingService trackRecordingService) throws RemoteException, InterruptedException { Location location = new Location("gps"); location.setLongitude(35.0f); location.setLatitude(45.0f); location.setAccuracy(5); location.setSpeed(10); location.setTime(System.currentTimeMillis()); location.setBearing(3.0f); trackRecordingService.insertTrackPoint(location); Thread.sleep(200); }
Example 14
Source File: DatabaseHandler.java From GPSLogger with GNU General Public License v3.0 | 4 votes |
public List<LocationExtended> getLocationsList(long TrackID, long startNumber, long endNumber) { List<LocationExtended> locationList = new ArrayList<>(); String selectQuery = "SELECT * FROM " + TABLE_LOCATIONS + " WHERE " + KEY_TRACK_ID + " = " + TrackID + " AND " + KEY_LOCATION_NUMBER + " BETWEEN " + startNumber + " AND " + endNumber + " ORDER BY " + KEY_LOCATION_NUMBER; //Log.w("myApp", "[#] DatabaseHandler.java - getLocationList(" + TrackID + ", " + startNumber + ", " +endNumber + ") ==> " + selectQuery); SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); double lcdata_double; float lcdata_float; if (cursor != null) { // looping through all rows and adding to list if (cursor.moveToFirst()) { do { Location lc = new Location("DB"); lc.setLatitude(cursor.getDouble(3)); lc.setLongitude(cursor.getDouble(4)); lcdata_double = cursor.getDouble(5); if (lcdata_double != NOT_AVAILABLE) lc.setAltitude(lcdata_double); //else lc.removeAltitude(); lcdata_float = cursor.getFloat(6); if (lcdata_float != NOT_AVAILABLE) lc.setSpeed(lcdata_float); //else lc.removeSpeed(); lcdata_float = cursor.getFloat(7); if (lcdata_float != NOT_AVAILABLE) lc.setAccuracy(lcdata_float); //else lc.removeAccuracy(); lcdata_float = cursor.getFloat(8); if (lcdata_float != NOT_AVAILABLE) lc.setBearing(lcdata_float); //else lc.removeBearing(); lc.setTime(cursor.getLong(9)); LocationExtended extdloc = new LocationExtended(lc); extdloc.setNumberOfSatellites(cursor.getInt(10)); extdloc.setNumberOfSatellitesUsedInFix(cursor.getInt(12)); locationList.add(extdloc); // Add Location to list } while (cursor.moveToNext()); } cursor.close(); } return locationList; }
Example 15
Source File: TrackRecordingServiceTest.java From mytracks with Apache License 2.0 | 4 votes |
private void fullRecordingSession() throws Exception { ITrackRecordingService service = bindAndGetService(createStartIntent()); assertFalse(service.isRecording()); // Start a track. long id = service.startNewTrack(); assertTrue(id >= 0); assertTrue(service.isRecording()); Track track = providerUtils.getTrack(id); assertNotNull(track); assertEquals(id, track.getId()); assertEquals(id, PreferencesUtils.getLong(context, R.string.recording_track_id_key)); assertEquals(id, service.getRecordingTrackId()); // Insert a few points, markers and statistics. long startTime = System.currentTimeMillis(); for (int i = 0; i < 30; i++) { Location loc = new Location("gps"); loc.setLongitude(35.0f + i / 10.0f); loc.setLatitude(45.0f - i / 5.0f); loc.setAccuracy(5); loc.setSpeed(10); loc.setTime(startTime + i * 10000); loc.setBearing(3.0f); service.insertTrackPoint(loc); if (i % 10 == 0) { service.insertWaypoint(WaypointCreationRequest.DEFAULT_STATISTICS); } else if (i % 7 == 0) { service.insertWaypoint(WaypointCreationRequest.DEFAULT_WAYPOINT); } } // Stop the track. Validate if it has correct data. service.endCurrentTrack(); assertFalse(service.isRecording()); assertEquals(-1L, service.getRecordingTrackId()); track = providerUtils.getTrack(id); assertNotNull(track); assertEquals(id, track.getId()); TripStatistics tripStatistics = track.getTripStatistics(); assertNotNull(tripStatistics); assertTrue(tripStatistics.getStartTime() > 0); assertTrue(tripStatistics.getStopTime() >= tripStatistics.getStartTime()); }
Example 16
Source File: AbstractFileTrackImporter.java From mytracks with Apache License 2.0 | 4 votes |
/** * Gets a track point. */ protected Location getTrackPoint() throws SAXException { Location location = createLocation(); // Calculate derived attributes from the previous point if (trackData.lastLocationInCurrentSegment != null && trackData.lastLocationInCurrentSegment.getTime() != 0) { long timeDifference = location.getTime() - trackData.lastLocationInCurrentSegment.getTime(); // Check for negative time change if (timeDifference <= 0) { Log.w(TAG, "Time difference not postive."); } else { /* * We don't have a speed and bearing in GPX, make something up from the * last two points. GPS points tend to have some inherent imprecision, * speed and bearing will likely be off, so the statistics for things * like max speed will also be off. */ double duration = timeDifference * UnitConversions.MS_TO_S; double speed = trackData.lastLocationInCurrentSegment.distanceTo(location) / duration; location.setSpeed((float) speed); } location.setBearing(trackData.lastLocationInCurrentSegment.bearingTo(location)); } if (!LocationUtils.isValidLocation(location)) { throw new SAXException(createErrorMessage("Invalid location detected: " + location)); } if (trackData.numberOfSegments > 1 && trackData.lastLocationInCurrentSegment == null) { /* * If not the first segment, add a resume separator before adding the * first location. */ insertLocation( createLocation(TrackRecordingService.RESUME_LATITUDE, 0.0, 0.0, location.getTime())); } trackData.lastLocationInCurrentSegment = location; return location; }
Example 17
Source File: LocationService.java From trekarta with GNU General Public License v3.0 | 4 votes |
public void run() { mMockCallback.postDelayed(this, LOCATION_DELAY); mMockLocationTicker++; // 200 ticks - 60 seconds int ddd = mMockLocationTicker % 200; // Search for satellites for first 3 seconds and each 1 minute if (ddd >= 0 && ddd < 10) { mGpsStatus = GPS_SEARCHING; mFSats = mMockLocationTicker % 10; mTSats = 25; mContinuous = false; updateGpsStatus(); return; } if (mGpsStatus == GPS_SEARCHING) { mGpsStatus = GPS_OK; updateGpsStatus(); } mLastKnownLocation = new Location(LocationManager.GPS_PROVIDER); mLastKnownLocation.setTime(System.currentTimeMillis()); mLastKnownLocation.setAccuracy(3 + mMockLocationTicker % 100); mLastKnownLocation.setSpeed(20); mLastKnownLocation.setAltitude(20 + mMockLocationTicker); //mLastKnownLocation.setLatitude(34.865792); //mLastKnownLocation.setLongitude(32.351646); //mLastKnownLocation.setBearing((System.currentTimeMillis() / 166) % 360); //mLastKnownLocation.setAltitude(169); /* double lat = 55.813557; double lon = 37.645524; if (ddd < 50) { lat += ddd * 0.0001; mLastKnownLocation.setBearing(0); } else if (ddd < 100) { lat += 0.005; lon += (ddd - 50) * 0.0001; mLastKnownLocation.setBearing(90); } else if (ddd < 150) { lat += (150 - ddd) * 0.0001; lon += 0.005; mLastKnownLocation.setBearing(180); } else { lon += (200 - ddd) * 0.0001; mLastKnownLocation.setBearing(270); } */ double lat = 60.0 + mMockLocationTicker * 0.0001; double lon = 30.3; if (ddd < 10) { mLastKnownLocation.setBearing(ddd); } if (ddd < 90) { mLastKnownLocation.setBearing(10); } else if (ddd < 110) { mLastKnownLocation.setBearing(100 - ddd); } else if (ddd < 190) { mLastKnownLocation.setBearing(-10); } else { mLastKnownLocation.setBearing(-200 + ddd); } mLastKnownLocation.setLatitude(lat); mLastKnownLocation.setLongitude(lon); mNmeaGeoidHeight = 0; updateLocation(); mContinuous = true; }
Example 18
Source File: LocationServiceTest.java From background-geolocation-android with Apache License 2.0 | 4 votes |
@Test(timeout = 5000) public void testOnLocationOnStoppedService() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(3); BroadcastReceiver serviceBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); int action = bundle.getInt("action"); if (action == LocationServiceImpl.MSG_ON_SERVICE_STARTED) { latch.countDown(); mService.stop(); //mService.onDestroy(); } if (action == LocationServiceImpl.MSG_ON_SERVICE_STOPPED) { latch.countDown(); mService.onLocation(new BackgroundLocation()); } if (action == LocationServiceImpl.MSG_ON_LOCATION) { latch.countDown(); } } }; LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(InstrumentationRegistry.getTargetContext()); lbm.registerReceiver(serviceBroadcastReceiver, new IntentFilter(LocationServiceImpl.ACTION_BROADCAST)); Config config = Config.getDefault(); config.setStartForeground(false); MockLocationProvider provider = new MockLocationProvider(); Location location = new Location("gps"); location.setProvider("mock"); location.setElapsedRealtimeNanos(2000000000L); location.setAltitude(100); location.setLatitude(49); location.setLongitude(5); location.setAccuracy(105); location.setSpeed(50); location.setBearing(1); provider.setMockLocations(Arrays.asList(location)); mLocationProviderFactory.setProvider(provider); mService.setLocationProviderFactory(mLocationProviderFactory); mService.configure(config); mService.start(); latch.await(); lbm.unregisterReceiver(serviceBroadcastReceiver); }
Example 19
Source File: NmeaParser.java From Androzic with GNU General Public License v3.0 | 4 votes |
private boolean updateTime(String time) { if (time.length() < 6) { return false; } if (mYear == -1) { // Since we haven't seen a day/month/year yet, // we can't construct a meaningful time stamp. // Clean up any old data. mLatitude = 0.0; mLongitude = 0.0; mHasAltitude = false; mHasBearing = false; mHasSpeed = false; mExtras = null; return false; } int hour, minute; float second; try { hour = Integer.parseInt(time.substring(0, 2)); minute = Integer.parseInt(time.substring(2, 4)); second = Float.parseFloat(time.substring(4, time.length())); } catch (NumberFormatException nfe) { Log.e(TAG, "Error parsing timestamp " + time); return false; } int isecond = (int) second; int millis = (int) ((second - isecond) * 1000); Calendar c = new GregorianCalendar(sUtcTimeZone); c.set(mYear, mMonth, mDay, hour, minute, isecond); long newTime = c.getTimeInMillis() + millis; if (mTime == -1) { mTime = 0; mBaseTime = newTime; } newTime -= mBaseTime; // If the timestamp has advanced, copy the temporary data // into a new Location if (newTime != mTime) { mNewWaypoint = true; mLocation = new Location(mName); mLocation.setTime(mTime); mLocation.setLatitude(mLatitude); mLocation.setLongitude(mLongitude); if (mHasAltitude) { mLocation.setAltitude(mAltitude); } if (mHasBearing) { mLocation.setBearing(mBearing); } if (mHasSpeed) { mLocation.setSpeed(mSpeed); } mLocation.setExtras(mExtras); mExtras = null; mTime = newTime; mHasAltitude = false; mHasBearing = false; mHasSpeed = false; } return true; }
Example 20
Source File: DatabaseHandler.java From GPSLogger with GNU General Public License v3.0 | 4 votes |
public List<LocationExtended> getPlacemarksList(long TrackID, long startNumber, long endNumber) { List<LocationExtended> placemarkList = new ArrayList<>(); String selectQuery = "SELECT * FROM " + TABLE_PLACEMARKS + " WHERE " + KEY_TRACK_ID + " = " + TrackID + " AND " + KEY_LOCATION_NUMBER + " BETWEEN " + startNumber + " AND " + endNumber + " ORDER BY " + KEY_LOCATION_NUMBER; //Log.w("myApp", "[#] DatabaseHandler.java - getLocationList(" + TrackID + ", " + startNumber + ", " +endNumber + ") ==> " + selectQuery); SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); double lcdata_double; float lcdata_float; if (cursor != null) { // looping through all rows and adding to list if (cursor.moveToFirst()) { do { Location lc = new Location("DB"); lc.setLatitude(cursor.getDouble(3)); lc.setLongitude(cursor.getDouble(4)); lcdata_double = cursor.getDouble(5); if (lcdata_double != NOT_AVAILABLE) lc.setAltitude(lcdata_double); //else lc.removeAltitude(); lcdata_float = cursor.getFloat(6); if (lcdata_float != NOT_AVAILABLE) lc.setSpeed(lcdata_float); //else lc.removeSpeed(); lcdata_float = cursor.getFloat(7); if (lcdata_float != NOT_AVAILABLE) lc.setAccuracy(lcdata_float); //else lc.removeAccuracy(); lcdata_float = cursor.getFloat(8); if (lcdata_float != NOT_AVAILABLE) lc.setBearing(lcdata_float); //else lc.removeBearing(); lc.setTime(cursor.getLong(9)); LocationExtended extdloc = new LocationExtended(lc); extdloc.setNumberOfSatellites(cursor.getInt(10)); extdloc.setNumberOfSatellitesUsedInFix(cursor.getInt(13)); extdloc.setDescription(cursor.getString(12)); placemarkList.add(extdloc); // Add Location to list } while (cursor.moveToNext()); } cursor.close(); } return placemarkList; }