If you really have to use they accelerometer, you could make a naive estimate looking at the amount of activity (peaks) in the data.
- Little or no peaks = no movement
- Some and diverse peaks = walking speed
- Many peaks = running speed
This could be done by simply saving a window of accelerometer data and count the number of values exceeding a given threshold.
Alternatively an more advanced, you could do Fast Fourier Transformation on the data to determine the frequency of the data, low frequency: low activity and vica versa.
The idea could be further improved using Machine Learning and possibly fusing with more sensors such as gyroscope, or compass. This will help more accurately determine the activity but is a rather big topic and will require a lot of time and effort.
Android can detect some user activities but is not that fine grained: http://developer.android.com/training/location/activity-recognition.html
The link can though help to determine when it makes sense to turn on the accelerometer as it is able to determine when the user is on foot:
public class ActivityRecognitionIntentService extends IntentService {
...
/**
* Map detected activity types to strings
*@param activityType The detected activity type
*@return A user-readable name for the type
*/
private String getNameFromType(int activityType) {
switch(activityType) {
case DetectedActivity.IN_VEHICLE:
return "in_vehicle";
case DetectedActivity.ON_BICYCLE:
return "on_bicycle";
case DetectedActivity.ON_FOOT:
return "on_foot";
case DetectedActivity.STILL:
return "still";
case DetectedActivity.UNKNOWN:
return "unknown";
case DetectedActivity.TILTING:
return "tilting";
}
return "unknown";
}
...
}