Understand the starter projectĪll right, you're set up and ready to add activity recognition. In addition, if you get a prompt saying "Reload for language changes to take effect?" or something similar, select "Yes". This will allow Android Studio to pull in all the necessary components. We recommend that you wait until this has finished before making code changes. During this time you will see a spinner in the status bar at the bottom of Android Studio: Please note that Android Studio might take several seconds to compile the project in the background for the first time.
There are two folder icons ( base and complete). (If you are in the Project view, you will need to expand the project to see the same thing.) In the upper-left corner of the project window, you should see something like the image below if you are in the Android view. (You won't be pushing any changes back to the Git repo.) Start Android Studio, and select "Open an existing Android Studio project" from the Welcome screen and open the project directory.Īfter the project has loaded, you may also see an alert that Git isn't tracking all your local changes, you can click " Ignore" or the " X" in the upper right.
If you do not have git you can get the project as a zip file:įile_downloadDownload Zip Import the project (You can check by typing git -version in the terminal / command line and verify it executes correctly.) git clone If you have git installed, you can simply run the command below. To get you started as quickly as possible, we have prepared a starter project for you to build on.
In this codelab, you will learn how to use the Activity Recognition Transition API to determine when a user starts/stops an activity like walking or running. Similarly, a parking detection app can ask, "tell me when the user has exited a vehicle and started walking", to save the user's parking location. Your app simply subscribes to a transition in activities you are interested in and the API notifies you of the changesĪs an example, a messaging app can ask, "tell me when the user has entered or exited a vehicle", to set the user's status as busy. The Activity Recognition Transition API solves these problems by providing a simple API that does all the processing for you and just tells you what you actually care about: when a user's activity has changed. Even worse, when apps are independently and continuously checking for changes in user activity, battery life suffers. To do this in the past, developers spent valuable engineering time combining various signals (location,sensor, etc.) to determine when an activity like walking or driving had started or ended. We carry phones with us everywhere, but until now, it's been hard for apps to adjust their experience to a user's continually changing environment and activity.