Book Image

Android Sensor Programming By Example

By : Varun Nagpal
Book Image

Android Sensor Programming By Example

By: Varun Nagpal

Overview of this book

Android phones available in today’s market have a wide variety of powerful and highly precise sensors. Interesting applications can be built with them such as a local weather app using weather sensors, analyzing risky driving behavior using motion sensors, a fitness tracker using step-counter sensors, and so on. Sensors in external devices such as Android Watch, Body Analyzer & Weight Machine, Running Speed Cell, and so on can also be connected and used from your Android app running on your phone. Moving further, this book will provide the skills required to use sensors in your Android applications. It will walk you through all the fundamentals of sensors and will provide a thorough understanding of the Android Sensor Framework. You will also get to learn how to write code for the supportive infrastructure such as background services, scheduled and long running background threads, and databases for saving sensor data. Additionally, you will learn how to connect and use sensors in external devices from your Android app using the Google Fit platform. By the end of the book, you will be well versed in the use of Android sensors and programming to build interactive applications.
Table of Contents (13 chapters)
Android Sensor Programming By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Authorization and permission scopes


User authorization is required before your application can read or write any fitness sensor data. User authorization is a two-step process. Step one is the registration of your application with the Google developer console, which is done outside your application. Step two is getting authorization from the user by using relevant scopes inside your application.

Registration with the Google developer console

Every application that needs to access fitness sensor data needs to register with the Google developer console. The followings steps explain the registration process:

  1. Open the Google developer console in any browser.
  2. Create a project from the console and enter your project name, which could be the same or different from your application name.
  3. Find the Fitness API from the APIs and Auth console menu and turn it on. Now Fitness API should appear at the top of your API list.
  4. Go to the Credential console menu and click on Create a new Client ID. This will open...