..


Sponsored Links

Structure of an Android application

For the moment put aside the HelloWorld project created in the previous chapter because, in order to analyze the files and code that have been created, you must have a solid foundation on the structure of an Android application, we have not bases.

Let's start by saying that when we clicked on the icon to run the Eclipse Java compiler we relied on the applications for Android, which, in case there are no errors in the code, create a file. Epk containing all the code of ' application.
This file is the application and therefore this is the file that will be installed on the physical devices.

Let's see what are the characteristics, in terms of relations with the operating system, Android application:

  • Each execution generates a single Linux process which is terminated as soon as the Android application is closed.
  • Each process has its own virtual machine (required to run a java file), which has the task of managing the process. This implies that each process runs independently from Android, isolated from the rest of the operations and other system routines.
  • Each application is associated with a unique user ID. This feature allows the application files to be visible to all other applications that have the same User ID and the application itself.

As we have said one of the main features of Android apps is the ability to share common elements. For example, if an application we have created a slideshow of pictures taken by the user through the photos taken with the camera and in another application we need the same slide is not necessary to include, within the second application, the code source of the slideshow. Nor is it necessary to link the code directly, it will simply request to carry out its part of the Android code for the slideshow of the first operation.

For this reason, it is obvious that another property of Android applications is not to have a single access point to run, how could it be for a Java project where the execution of the project is delegated exclusively to the main () function.

And 'possible to identify four different components in an application Android: the actvities (which will be in the next chapter), the services, the broadcast content providers and receivers.

Services

The peculiarity of this-component is to not have any graphical user interface (which instead has an activity), typically run in the background. An example of a service might be the music player running in the background while the user performs other actions. Each service class extends Services.

Broadcast receivers

A-component of this type must not engage in pre-operation, but rather listens and reacts accordingly when capturing an ad. Who sends these announcements is usually the operating system that a message notifies applications, such as that was finished downloading a file that is then available to the user. Obviously in our application we can teach our receivers to react only to certain types of ads. All receivers BroadcastReceiver extend the class.

Content providers

The task-component of this is to make available a data set of a certain application to other applications. Usually the data that we want to make, so to speak, "public" or are saved in the file system or in a SQLite database. A content provider extends the base class ContentProvider.

In the next chapter we will present, in a very comprehensive, what are the Activities and what are their characteristics.

Help develop applications for Android
E-Learning
Flash MX (Advanced) Flash MX (Advanced)
Become a designer of Web sites from 29 €.
Photoshop (Course) Photoshop (Course)
Web graphics and photo editing with the popular Adobe Photoshop. From 49 €.
SQL and Database (Course) SQL and Database (Course)
Create and manage relational databases. From 39 €.
Sponsored Links