Added a null check for the location service's intent.

if the intent is null, the service will be stopped, and the event will
be logged.

closes #141
This commit is contained in:
2012-08-16 11:31:29 -04:00
parent 4179211897
commit 1f3a6680fe

View File

@@ -208,7 +208,10 @@ public class LocationService extends Service implements LocationListener {
* @author ricky barrette * @author ricky barrette
*/ */
private void parseIntent(final Intent intent) { private void parseIntent(final Intent intent) {
if(intent == null){
this.stopSelf(mStartId);
Log.e(TAG, "LocationService intent was null, stopping selft: " + mStartId);
} else {
mIntent = intent; mIntent = intent;
if (intent.hasExtra(LocationLibraryConstants.INTENT_EXTRA_PERIOD_BETWEEN_UPDATES)) if (intent.hasExtra(LocationLibraryConstants.INTENT_EXTRA_PERIOD_BETWEEN_UPDATES))
@@ -217,6 +220,7 @@ public class LocationService extends Service implements LocationListener {
if (intent.hasExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY)) if (intent.hasExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY))
mRequiredAccuracy = intent.getIntExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, LocationLibraryConstants.MINIMUM_REQUIRED_ACCURACY); mRequiredAccuracy = intent.getIntExtra(LocationLibraryConstants.INTENT_EXTRA_REQUIRED_ACCURACY, LocationLibraryConstants.MINIMUM_REQUIRED_ACCURACY);
} }
}
/** /**
* registers this service to be waken up by android's alarm manager * registers this service to be waken up by android's alarm manager