Listing 4-49. Service Receiving Motion Updates

public class UserMotionService extends IntentService {    private static final String TAG = "UserMotionService";    /*     * Callback interface for detected activity type changes     */    public interface OnActivityChangedListener{        public void onUserActivityChanged(int bestChoice,                int bestConfidence,                ActivityRecognitionResult newActivity);    }    /* Last detected activity type */    private DetectedActivity mLastKnownActivity;    /*     * Marshals requests from the background thread so the     * callbacks can be made on the main (UI) thread.     */    private CallbackHandler mHandler;    private static class CallbackHandler extends Handler {        /* Callback ...

Get Android Recipes: A Problem-Solution Approach for Android 5.0, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.