Home | History | Annotate | only in /developers/build/prebuilts/gradle/JumpingJack
Up to higher level directory
NameDateSize
.google/06-Dec-2016
Application/06-Dec-2016
build.gradle06-Dec-201614
CONTRIB.md06-Dec-20161.6K
CONTRIBUTING.md06-Dec-20161.5K
gradle/06-Dec-2016
gradlew06-Dec-20165K
gradlew.bat06-Dec-20162.3K
LICENSE06-Dec-201631.5K
NOTICE06-Dec-2016614
README.md06-Dec-20163.2K
screenshots/06-Dec-2016
settings.gradle06-Dec-201621
Wearable/06-Dec-2016

README.md

      1 
      2 Android JumpingJack Sample
      3 ===================================
      4 
      5 A basic sample showing how to use the Gravity sensor on the wearable device
      6 by counting how many jumping jacks you have performed.
      7 
      8 Introduction
      9 ------------
     10 
     11 [SensorEventListener][1] offers you methods used for receiving notifications from the
     12 [SensorManager][2] when sensor values have changed.
     13 
     14 This example counts how many times Jumping Jacks are performed by detecting the value
     15 of the Gravity sensor by the following code:
     16 
     17 ```java
     18 @Override
     19 public void onSensorChanged(SensorEvent event) {
     20     detectJump(event.values[0], event.timestamp);
     21 }
     22 
     23 private void detectJump(float xValue, long timestamp) {
     24     if ((Math.abs(xValue) > GRAVITY_THRESHOLD)) {
     25         if(timestamp - mLastTime < TIME_THRESHOLD_NS && mUp != (xValue > 0)) {
     26             onJumpDetected(!mUp);
     27         }
     28         mUp = xValue > 0;
     29         mLastTime = timestamp;
     30     }
     31 }
     32 ```
     33 
     34 The detectJump method above assumes that when a person is wearing the watch, the x-component of gravity
     35 as measured by the Gravity Sensor is +9.8 when the hand is downward and -9.8 when the hand
     36 is upward (signs are reversed if the watch is worn on the right hand). Since the upward or
     37 downward may not be completely accurate, we leave some room and instead of 9.8, we use
     38 GRAVITY_THRESHOLD (7.0f). We also consider the up <-> down movement successful if it takes less than
     39 TIME_THRESHOLD_NS (2000000000 nanoseconds).
     40 
     41 [1]: http://developer.android.com/reference/android/hardware/SensorEventListener.html
     42 [2]: http://developer.android.com/reference/android/hardware/SensorManager.html
     43 
     44 Pre-requisites
     45 --------------
     46 
     47 - Android SDK 24
     48 - Android Build Tools v24.0.2
     49 - Android Support Repository
     50 
     51 Screenshots
     52 -------------
     53 
     54 <img src="screenshots/jumping_jack.gif" height="400" alt="Screenshot"/> 
     55 
     56 Getting Started
     57 ---------------
     58 
     59 This sample uses the Gradle build system. To build this project, use the
     60 "gradlew build" command or use "Import Project" in Android Studio.
     61 
     62 Support
     63 -------
     64 
     65 - Google+ Community: https://plus.google.com/communities/105153134372062985968
     66 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
     67 
     68 If you've found an error in this sample, please file an issue:
     69 https://github.com/googlesamples/android-JumpingJack
     70 
     71 Patches are encouraged, and may be submitted by forking this project and
     72 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
     73 
     74 License
     75 -------
     76 
     77 Copyright 2016 The Android Open Source Project, Inc.
     78 
     79 Licensed to the Apache Software Foundation (ASF) under one or more contributor
     80 license agreements.  See the NOTICE file distributed with this work for
     81 additional information regarding copyright ownership.  The ASF licenses this
     82 file to you under the Apache License, Version 2.0 (the "License"); you may not
     83 use this file except in compliance with the License.  You may obtain a copy of
     84 the License at
     85 
     86 http://www.apache.org/licenses/LICENSE-2.0
     87 
     88 Unless required by applicable law or agreed to in writing, software
     89 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     90 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
     91 License for the specific language governing permissions and limitations under
     92 the License.
     93