Code example for LocationManager

Methods: removeGpsStatusListenerremoveUpdates

0
	} 
	public static void unregisterOnThread(Context context, LocationListener locationCallback, Listener listener) {
		Log.i(TAG,"Unregister for location events");
		LocationManager locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
		if (locationCallback!=null)
			locationManager.removeUpdates(locationCallback);
		if (listener!=null)
			locationManager.removeGpsStatusListener(listener);
	} 
	private static LocationCallback locationCallback;
	static class LocationCallback implements LocationListener, GpsStatus.Listener {
		private Context context;
		LocationCallback(Context context) {
			this.context = context;
		} 
		@Override 
		public void onLocationChanged(Location loc) {
			Log.i(TAG,"Location provider="+loc.getProvider()+", lat="+loc.getLatitude()+", long="+loc.getLongitude()+", bearing="+(loc.hasBearing() ? ""+loc.getBearing() : "NA")+", speed="+(loc.hasSpeed() ? ""+loc.getSpeed() : "NA")+", accuracy="+(loc.hasAccuracy() ? ""+loc.getAccuracy() : "NA")+", alt="+(loc.hasAltitude() ? ""+loc.getAltitude() : "NA"));
			try { 
				JSONStringer js = new JSONStringer();
				// as er Aether's notebook