Tuesday, April 26, 2011

Android Entries: Activity

To launch an Android application with all the events we mentioned previously, we will be using the Android Activity API.

Acvitity
To do this, we extends our entry class with the Android Activity class which has a function onCreate() for us to override. The onCreate() function will be called when our application is loaded and launched, acts as the initializer.
But the more important reason we use the Activity is because we can grab many resources and handles in it.
For example, the View clusters.

View
In Android the class View deals with all the drawings on the screen, displays and hardware information: pixel dpi and so on.  Extension of View class allows us to use Canvas, GLSL shading, openGL and all kinds of customized drawing/rendering technique. And in the Activity we can set our View instance to the currentView, sounds like loading different GLSL shaders in the same application.

Activity's Functions:
Also the Activity allows us to request current resources like requestWindowFeature(), or request device information using getDeviceConfigurationInfo() before we launch different Views.
These information can tell us what version of GLSL does our current device use; what is the windows size and what is the scr dpi -- etc.
For Android platform we will encounter huge number of different device.  With the Activity class we will be able to deal with them.

Now we know our application entry point and how do we display with what we want, the steps are quite simple:
create an instance of our customized View (or any default View classes) using the parameters we get from the Activity.
Launch our view with setContentView(view); 

No comments:

Post a Comment