Giter Site home page Giter Site logo

msoftware / androidwearmotionsensors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from estherjk/androidwearmotionsensors

0.0 1.0 0.0 167 KB

Using the accelerometer and gyroscope on an Android Wear device

Home Page: http://esthermakes.tech/projects/AndroidWearMotionSensors/

License: MIT License

Java 100.00%

androidwearmotionsensors's Introduction

Android Wear Motion Sensors

This project demonstrates the use of the accelerometer and gyroscope sensors on an Android Wear device. It displays the raw values for each sensor on its own page. It also performs simple shake and rotation detection using the accelerometer and gyroscope, respectively; when a shake or a rotation is detected, the background color changes to green.

See it in action here using the Moto 360.

Code Overview

The Java files of interest are in wear/src/main/java:

As the name suggests, MainActivity.java contains the code for the main activity. The 2D Picker pattern for Android Wear is used to page through the accelerometer and gyroscope fragments. This is accomplished by adding a GridViewPager element to the activity and setting an adapter that provides the pages by extending FragmentGridPagerAdapter (see SensorFragmentPagerAdapter.java). It also contains a DotsPageIndicator to identify which page is active.

SensorFragment.java provides the UI behavior for a sensor by displaying the raw data (available through the standard Android API) and performing simple shake / rotation detection. When instantiating a sensor fragment, the newInstance() function is used to specify the desired sensor (i.e. accelerometer or gyroscope). See SensorFragmentPagerAdapter.java to see how this is accomplished.

androidwearmotionsensors's People

Contributors

kubark42 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.