Cleaned up some code in the Location service and android gps classes

This commit is contained in:
2012-07-21 22:38:38 -04:00
parent 1bc12ce660
commit 6fcc65a605
3 changed files with 3 additions and 35 deletions

View File

@@ -16,7 +16,7 @@
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
android:targetSdkVersion="15" /> android:targetSdkVersion="16" />
<uses-feature <uses-feature
android:name="android.hardware.location" android:name="android.hardware.location"

View File

@@ -137,14 +137,6 @@ public class AndroidGPS implements LocationListener {
* @author ricky barrette * @author ricky barrette
*/ */
private void requestUpdates() { private void requestUpdates() {
try {
mLocationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, this);
} catch (final IllegalArgumentException e) {
e.printStackTrace();
/* We do no handle this exception as it is caused if the android version is < 1.6. since the PASSIVE_PROVIDER call is not required
* to function we can ignore it.
*/
}
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
} }

View File

@@ -14,7 +14,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.location.Location; import android.location.Location;
import android.location.LocationListener; import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
@@ -27,13 +26,6 @@ import com.TwentyCodes.android.debug.LocationLibraryConstants;
/** /**
* This service class will be used broadcast the users location either one time, or periodically. * This service class will be used broadcast the users location either one time, or periodically.
* To use as a one shot location service:
* <blockquote><pre>PendingIntent pendingIntent = PendingIntent.getService(context, 0, LocationService.startService(context), 0);
* or
* Intent service = new Intent(context, LocationService.class);
* context.startService(service);<pre></bloackquote>
* To use as a recurring service:
* <blockquote>LocationService.startService(this, (60000 * Integer.parseInt(ringer.getString(UPDATE_INTVERVAL , "5")))).run();</bloackquote>
* @author ricky barrette * @author ricky barrette
*/ */
public class LocationService extends Service implements LocationListener { public class LocationService extends Service implements LocationListener {
@@ -65,7 +57,7 @@ public class LocationService extends Service implements LocationListener {
}; };
} }
private WakeLock mWakeLock; private WakeLock mWakeLock;
private long mPeriod = -1; protected long mPeriod = -1;
private Location mLocation; private Location mLocation;
private int mStartId; private int mStartId;
private AndroidGPS mLocationManager; private AndroidGPS mLocationManager;
@@ -97,7 +89,7 @@ public class LocationService extends Service implements LocationListener {
locationUpdate.setAction(mIntent.getAction()); locationUpdate.setAction(mIntent.getAction());
else else
locationUpdate.setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE); locationUpdate.setAction(LocationLibraryConstants.INTENT_ACTION_UPDATE);
locationUpdate.putExtra(LocationManager.KEY_LOCATION_CHANGED, mLocation); locationUpdate.putExtra(LocationLibraryConstants.INTENT_EXTRA_LOCATION_CHANGED, mLocation);
sendBroadcast(locationUpdate); sendBroadcast(locationUpdate);
stopSelf(mStartId); stopSelf(mStartId);
} }
@@ -174,21 +166,6 @@ public class LocationService extends Service implements LocationListener {
} }
/**
* To keep backwards compatibility we override onStart which is the equivalent of onStartCommand in pre android 2.x
* @author ricky barrette
*/
@Override
public void onStart(final Intent intent, final int startId) {
if(Debug.DEBUG)
Log.i(TAG, "onStart.Service started with start id of: " + startId);
mStartId = startId;
parseIntent(intent);
mLocationManager.enableLocationUpdates(this);
}
/** /**
* This method is called when startService is called. only used in 2.x android. * This method is called when startService is called. only used in 2.x android.
* @author ricky barrette * @author ricky barrette
@@ -208,7 +185,6 @@ public class LocationService extends Service implements LocationListener {
@Override @Override
public void onStatusChanged(final String provider, final int status, final Bundle extras) { public void onStatusChanged(final String provider, final int status, final Bundle extras) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/** /**