Game Development Reference
In-Depth Information
Running the demo application on Android
The starter class for the Android application is called MainActivity.java . For a
Gradle-based project, the starter class will be AndroidLauncher.java .
The following listing is MainActivity.java from demo-android :
package com.packtpub.libgdx.demo;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.
AndroidApplicationConfiguration;
public class MainActivity extends AndroidApplication {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new
AndroidApplicationConfiguration();
initialize(new MyDemo(), cfg);
}
}
In the preceding code listing, you can see the MainActivity class that is inherited
from the AndroidApplication class. This is how LibGDX encapsulates tasks such as
creating a so-called activity that registers handlers to process touch input, read sensor
data, and much more. What is left to do for you is to create an instance of a class that
implements the ApplicationListener interface. In this case, it is an instance of the
MyDemo class. The instances of MyDemo and AndroidApplicationConfiguration are
passed as arguments to the initialize() method. If you are interested in the latest
development of Android hardware statistics, be sure to check out the Dashboards
section on the official Android developer website ( http://developer.android.com/
about/dashboards/index.html#OpenGL ) .
 
Search WWH ::




Custom Search