Nathan Tornquist.com

TiltBall.java: A Basic Android Application

I have recently been playing with the Android SDK. The following code is the culmination of my efforts so far. These files allow you to create an Activity that will run on the phone, create a Thread, and then create a SurfaceView that will act as the main application.

While there are no controls used, and the actual activity is fairly limited, these files demonstrate how to override a surfaceView, and take both touch and accelerometer input in the same class. Ultimately this is all of the basic framework needed to start building a game or other non-control based application.

The screen color and ball color both change based on the accelerometer input. The ball moves based on said input, and touching the screen relocates the ball to that position.