I'm researching ways on how to do activity recognition using an android smartwatch. Currently, I'm focusing on detecting whether the user is walking or standing still. My first idea was to use the built in step counter, but then I came across the Android Activity Recognition API (I'm relatively new to Android^^) which seems to be used in mobile apps only.
I'm now stucking at answering the following questions:
- Is the current API already making use of a connected wearable device? (e.g. automatically accessing built-in wearable sensors)
- Is there a seperate API available for Android Wear?
- Is there any other best practice on how to use wearables for activity recognition? (especially walking and standing still)
During my research I've already tried the following things:
- Reading through the Android Activity Recognition Guide
- Reading through this article about Google's Activity Recognition API
- Implementing a simple Android Wear App which uses the current Activity Recognition API. I tested the app on my LG G Watch without success. It seems like I can connect to the ActivityRecognitionClient but I never receive any activity updates. I tried the same code on my Nexus 5 - everything works fine.
- Reading through this post about Google Play Services. Here the author is like "...We like the Activity Recognition API for Android Wear, as we’ve always thought the location tracking technology was a great backbone for this type of functionality...". So according to this, there is a seperate API, right?
I would be very thankful for any helpful information from you guys. In my opinion, a cool thing (see first question) would be to automatically detect a connected wearable device and use its sensors for enhancing the accurancy when the mobile phone is unsure about the current user's activity.
You ask
Is the current API already making use of a connected wearable device? (e.g. automatically accessing built-in wearable sensors)
No, and this would not make sense would it? The wearable and handheld device is not always carried at the same time; the watch can be moving, and the handheld still. (vice versa) I am not sure what the value of a combined measurement would be.
Is there a seperate API available for Android Wear?
Yes. google provide a different Google Play Services library or wearables you see this in the compile dependencies;
compile'com.google.android.gms:play-services-wearable:6.5.87'
vs
compile 'com.google.android.gms:play-services:6.5.87'
So, when you tested the API in your first Moto360 app, you actually imported the play services libraries meant for handhelds instead of the wearable version. The constant "ActivityRecognition.API" is not included in the wearable version of the client API.
Is there any other best practice on how to use wearables for activity recognition? (especially walking and standing still)
One way would be to use the raw accelerometer data to detect motion. It is fairly easy to detect that the device is not moving at all, to detect anything else is not trivial.
You could push sensor data from the wearable to the handheld for processing there if you like. Ping me if you'd like some code showing just that. I don't want to post it since it is not relevant to the question.
My guess is that Google will include this API on the handheld device in the future. Spending a lot of time "rolling your own" might be a risk...
Unfortunately, the activity recognition API is not yet implemented on Wear devices. When I tested a simple ActivityRecognitionClient API example program on my Motorola Moto 360 (with "4.4W 2"), I got a message indicating that on the logcat stream.
来源:https://stackoverflow.com/questions/27040679/android-activity-recognition-on-wearables