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 live online training, plus books, videos, and digital content from nearly 200 publishers.