O'Reilly logo

Professional Android Programming with Mono for Android and .NET/C# by Chris Hardy, Jonathan Dick, John J. Croft IV, Nathan Blevins, Wallace B. McClure

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8

Programming with the Device Hardware

What's in This Chapter?

  • Using the sensor API
  • Programming accelerometer, device orientation, and proximity detection support
  • Supporting networking
  • Bluetooth programming

Android contains a vast amount of exciting hardware. This hardware in and of itself doesn't interest users; the excitement occurs when the application presents the users with information in a way that makes sense to them. This hardware is very interesting to developers building apps because it allows applications to provide extraordinary features based on it. This chapter looks at the sensor API, accelerometer, device orientation, proximity detection, networking, and Bluetooth. Here are some sample uses of this hardware:

  • A program can test whether a network is available over any connection (WiFi, 3G, or EDGE). If a connection does not exist, instead of seeing an error message when attempting to upload information, the user can be notified that there is no connection to a service.
  • The accelerometer can be used to pull random data from a data source. When the device is shaken, the application can respond by reading random data from a data source.
  • When the user changes the device from portrait to landscape, the application can change how it displays content to the user.

Working with Sensors

Android devices come with all types of exciting features, including accelerometers, compasses, microphones, gyroscopes, and other nifty hardware. This hardware allows devices to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required