diff --git a/LocationLib/bin/locationlib.jar b/LocationLib/bin/locationlib.jar index f886d68..ca2cbd3 100644 Binary files a/LocationLib/bin/locationlib.jar and b/LocationLib/bin/locationlib.jar differ diff --git a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java index e30d918..a077c77 100644 --- a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java +++ b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java @@ -13,13 +13,14 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.location.Location; +import android.location.LocationManager; import android.os.Handler; import android.os.IBinder; import android.util.Log; import com.TwentyCodes.android.debug.LocationLibraryConstants; import com.TwentyCodes.android.location.GeoPointLocationListener; -import com.TwentyCodes.android.location.LocationReceiver; +import com.TwentyCodes.android.location.BaseLocationReceiver; import com.google.android.maps.GeoPoint; import com.skyhookwireless.wps.RegistrationCallback; import com.skyhookwireless.wps.WPSContinuation; @@ -49,8 +50,8 @@ public class SkyHookService extends Service implements GeoPointLocationListener, public static final String INTENT_EXTRA_REQUIRED_ACCURACY = "required_accuracy"; /** - * Used to tell the service the update action to broadcast. If this is not supplied, {@link LocationReceiver.INTENT_EXTRA_ACTION_UPDATE } will be used. - * @see LocationReceiver.INTENT_EXTRA_ACTION_UPDATE + * Used to tell the service the update action to broadcast. If this is not supplied, {@link BaseLocationReceiver.INTENT_EXTRA_ACTION_UPDATE } will be used. + * @see BaseLocationReceiver.INTENT_EXTRA_ACTION_UPDATE */ public static final String INTENT_EXTRA_ACTION_UPDATE = "action_update"; @@ -75,8 +76,8 @@ public class SkyHookService extends Service implements GeoPointLocationListener, if(mIntent.getAction() != null) locationUpdate.setAction(mIntent.getAction()); else - locationUpdate.setAction(LocationReceiver.INTENT_EXTRA_ACTION_UPDATE); - locationUpdate.putExtra(LocationReceiver.INTENT_EXTRA_LOCATION_PARCEL, convertLocation()); + locationUpdate.setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE); + locationUpdate.putExtra(LocationManager.KEY_LOCATION_CHANGED, convertLocation()); sendBroadcast(locationUpdate); } } diff --git a/LocationLib/src/com/TwentyCodes/android/debug/LocationLibraryConstants.java b/LocationLib/src/com/TwentyCodes/android/debug/LocationLibraryConstants.java index 3552e2c..34072af 100644 --- a/LocationLib/src/com/TwentyCodes/android/debug/LocationLibraryConstants.java +++ b/LocationLib/src/com/TwentyCodes/android/debug/LocationLibraryConstants.java @@ -1,5 +1,5 @@ /** - * Debug.java + * LocationLibraryConstants.java * @date Mar 1, 2011 * @author ricky barrette * @author Twenty Codes, LLC @@ -7,6 +7,7 @@ package com.TwentyCodes.android.debug; import android.hardware.SensorManager; +import android.location.LocationManager; /** * This class will be used to set the Location Library Constants @@ -14,6 +15,12 @@ import android.hardware.SensorManager; */ public final class LocationLibraryConstants { + static{ + SUPPORTS_FROYO = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO; + + SUPPORTS_GINGERBREAD = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD; + } + /** * Sets the default SkyHook Registration Behavior used by SkyHookRegistration.getUserName() * @author ricky barrette @@ -47,10 +54,8 @@ public final class LocationLibraryConstants { public static final boolean SUPPORTS_FROYO; public static final boolean SUPPORTS_GINGERBREAD; + + public static final String INTENT_ACTION_UPDATE = "TwentyCodes.intent.action.LocationUpdate"; - static{ - SUPPORTS_FROYO = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO; - - SUPPORTS_GINGERBREAD = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD; - } + public static final String INTENT_EXTRA_LOCATION_CHANGED = LocationManager.KEY_LOCATION_CHANGED; } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/PassiveLocationChangedReceiver.java b/LocationLib/src/com/TwentyCodes/android/location/BaseLocationReceiver.java similarity index 77% rename from LocationLib/src/com/TwentyCodes/android/location/PassiveLocationChangedReceiver.java rename to LocationLib/src/com/TwentyCodes/android/location/BaseLocationReceiver.java index 19f18cb..1a618bb 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/PassiveLocationChangedReceiver.java +++ b/LocationLib/src/com/TwentyCodes/android/location/BaseLocationReceiver.java @@ -1,8 +1,7 @@ /** - * PassiveLocationChangedReceiver.java - * @date May 15, 2012 - * @author ricky barrette * @author Twenty Codes, LLC + * @author ricky barrette + * @date Oct 18, 2010 */ package com.TwentyCodes.android.location; @@ -13,11 +12,12 @@ import android.location.Location; import android.location.LocationManager; /** + * this abstract class will be used as a for classes wishing to be a receiver of location updates from the location services * @author ricky barrette */ -public abstract class PassiveLocationChangedReceiver extends BroadcastReceiver { - - protected Context mContext; +public abstract class BaseLocationReceiver extends BroadcastReceiver { + + public Context mContext; /** * (non-Javadoc) diff --git a/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java b/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java deleted file mode 100644 index 79178c3..0000000 --- a/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @author Twenty Codes, LLC - * @author ricky barrette - * @date Oct 18, 2010 - */ -package com.TwentyCodes.android.location; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.location.Location; - -/** - * this abstract class will be used as a for classes wishing to be a receiver of location updates from the location services - * @author ricky barrette - */ -public abstract class LocationReceiver extends BroadcastReceiver { - - public static final String INTENT_EXTRA_ACTION_UPDATE = "TwentyCodes.intent.action.LocationUpdate"; - public static final String INTENT_EXTRA_LOCATION_PARCEL = "location_parcel"; - public Context mContext; - - /** - * (non-Javadoc) - * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent) - * @param contextonBind - * @param intent - * @author ricky barrette - */ - @Override - public void onReceive(final Context context, final Intent intent) { - mContext = context; - if(intent.getParcelableExtra(INTENT_EXTRA_LOCATION_PARCEL) != null){ - Location location = intent.getParcelableExtra(INTENT_EXTRA_LOCATION_PARCEL); - onLocationUpdate(location); - } - } - - /** - * called when a location update is received - * @param parcelableExtra - * @author ricky barrette - */ - public abstract void onLocationUpdate(Location location); - -} \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/LocationService.java b/LocationLib/src/com/TwentyCodes/android/location/LocationService.java index 3ebb8a6..f903451 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/LocationService.java +++ b/LocationLib/src/com/TwentyCodes/android/location/LocationService.java @@ -14,6 +14,7 @@ import android.content.Context; import android.content.Intent; import android.location.Location; import android.location.LocationListener; +import android.location.LocationManager; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -48,8 +49,8 @@ public class LocationService extends Service implements LocationListener { public static final String INTENT_EXTRA_REQUIRED_ACCURACY = "required_accuracy"; /** - * Used to tell the service the update action to broadcast. If this is not supplied, {@link LocationReceiver.INTENT_EXTRA_ACTION_UPDATE } will be used. - * @see LocationReceiver.INTENT_EXTRA_ACTION_UPDATE + * Used to tell the service the update action to broadcast. If this is not supplied, {@link BaseLocationReceiver.INTENT_EXTRA_ACTION_UPDATE } will be used. + * @see BaseLocationReceiver.INTENT_EXTRA_ACTION_UPDATE */ public static final String INTENT_EXTRA_ACTION_UPDATE = "action_update"; @@ -95,8 +96,8 @@ public class LocationService extends Service implements LocationListener { if(mIntent.getAction() != null) locationUpdate.setAction(mIntent.getAction()); else - locationUpdate.setAction(LocationReceiver.INTENT_EXTRA_ACTION_UPDATE); - locationUpdate.putExtra(LocationReceiver.INTENT_EXTRA_LOCATION_PARCEL, mLocation); + locationUpdate.setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE); + locationUpdate.putExtra(LocationManager.KEY_LOCATION_CHANGED, mLocation); sendBroadcast(locationUpdate); stopSelf(mStartId); } diff --git a/LocationLib/src/com/TwentyCodes/android/location/PassiveLocationListener.java b/LocationLib/src/com/TwentyCodes/android/location/PassiveLocationListener.java index 91311f7..8f5ff10 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/PassiveLocationListener.java +++ b/LocationLib/src/com/TwentyCodes/android/location/PassiveLocationListener.java @@ -22,13 +22,13 @@ public class PassiveLocationListener { /** * A convenience method for requesting passive location updates * @param context + * @param receiverIntent * @author ricky barrette */ - public static final void requestPassiveLocationUpdates(final Context context){ + public static final void requestPassiveLocationUpdates(final Context context, final Intent receiverIntent){ if (LocationLibraryConstants.SUPPORTS_FROYO) { final LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - final Intent passiveIntent = new Intent(context, PassiveLocationChangedReceiver.class); - final PendingIntent locationListenerPassivePendingIntent = PendingIntent.getBroadcast(context, 0, passiveIntent, PendingIntent.FLAG_UPDATE_CURRENT); + final PendingIntent locationListenerPassivePendingIntent = PendingIntent.getBroadcast(context, 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT); locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, locationListenerPassivePendingIntent); } }