@Override public void onReceive(Context context, Intent intent) { // Log.d(Constants.TAG, // "TrackpointsListActivity: LOCATION BROADCAST MESSAGE RECEIVED"); Bundle bundle = intent.getExtras(); currentLocation = (Location) bundle.getParcelable("location"); waypointsArrayAdapter.sortByDistance(); // waypointsArrayAdapter.notifyDataSetChanged(); }
@Override public void run() { if (serviceConnection == null) { return; } AppService appService = serviceConnection.getService(); if (appService == null) { Toast.makeText( TrackpointsListActivity.this, R.string.gps_service_not_connected, Toast.LENGTH_SHORT) .show(); return; } if (!appService.isListening()) { // location updates stopped at this time, so let's start them appService.startLocationUpdates(); } else { // gpsInUse = false means we are in process of stopping // listening appService.setGpsInUse(true); // if both isListening and isGpsInUse are true - do nothing // most likely we are in the process of recording track } // this activity requires compass data appService.startSensorUpdates(); // let's not wait for LocationListener to receive updates and get last known location currentLocation = appService.getCurrentLocation(); waypointsArrayAdapter.notifyDataSetChanged(); }