Tracking Location Receiver doesn't work


#1

I can’t figure this one out but Tracking Location Receiver doesn’t work

In my experience if you want this line of code RunManager.getInstance(context).insertLocation(loc);
to actually work it needs to go in LocationReciever.onRecieve and NO OTHER PLACE
or in other words
This works

public void onReceive(Context context, Intent intent) 
	{
	//If you go a Location extra use it
	Location loc = (Location) intent.getParcelableExtra(LocationManager.KEY_LOCATION_CHANGED);
		if(loc !=null)
		{
		Log.i(TAG, "We have a location");
		onLocationReceived(context, loc);
		RunManager.getInstance(context).insertLocation(loc);
		return;
		}
		...........
	}

This Doesn’t work

protected void onLocationReceived(Context context, Location loc) { RunManager.getInstance(context).insertLocation(loc); Log.d(TAG, String.format("got location from %s : %.6f %.6f", loc.getProvider(), loc.getLatitude(), loc.getLongitude())); }
This also doesn’t work

public class TrackingLocationReceiver extends LocationReceiver 
{
private static final String TAG="TrackingLocationReceiver";
	@Override
	protected void onLocationReceived(Context context, Location loc)
	{
	Log.i(TAG,"Insert Location");
	RunManager.getInstance(context).insertLocation(loc);
	}

}

I really don’t know why this line of code must be executed within the onReceive() method but refuses to work when placed in the
onLocationReceived(…) method which is called by the onReceive() method :confused: :question:
So unless I can find a way to make it work the way the book suggests it should, I will use my cheat way