The Accelerometer input

We will now take a look at the accelerometer component on Android. If you don't know what an accelerometer is, it is something that is used to detect movement in Android. In layman terms, we can call it the motion sensor. The best example for this is any racing game that lets you control the car based on your phone's movement. This is something really interesting, which you can use in further chapters to apply motion to objects, so make sure that you grasp this properly. Type in the code you see in the following block starting from sensorManager:

    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_fullscreen);        final TextView tv =  (TextView) ...

Get Learning Android Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.