Thursday, December 1, 2011

Android Package Explorer

The below image shows the Android package Explorer found in the Java perspective in Eclipse, displays all the components of the sample Android application.

src folder : include the package for the sample application namely com.msi.infoaegis.
R.java : The Android Developer Tools [ADT] create this file automatically and represents the constants headed to access various resources of the Android application.

The R.java file is created upone build automatically the figure shows the R.java file for the sample application. So be sure to not modify it by hand as all changes will be lost.

The R class contains anonymous subclasses, which each contain identifiers for the various resources. Note that all of these classes are static.

R.layout main identifies represents the layout by main.xml. Recall this value is used in the OnCreate() method of the activity as follows setContentView(R.layout.main). This is the point at which a specific activity and a specific layout(main) are bound together at runtime.

Main.xml :The application contains a file named main.xml that represents the visual aspects of the primary UI of the activity. Note that there is no reference in the main.xml where the layout is used.This means it may be used in more than one activity if desired

Referenced libraries : Contains android.jar, which is the Android runtime class jar file, found in the Android SDK.
Res folder : Ccontains the resource for the application. Resources in android are organized into a subdirectory of the project named res. Resources fall into three primary categories

  1. Drawables: This folder contains graphics file such as icon and bitmap
  2. Layouts : This folder contains XML files that represent the layouts and views of the application
  3. Values :This folder contains a file named string.xml. This is the primary means for string localization for the application

AndroidManifest.xml

The AndroidManifest.xml file represent the development description for an Android application. The file lists any activity, service,content provider or receiver contained in the application along with the appropriate IntentFilters supported by the application

Things to note:

  1. The tag is in essence importing classes from This package.
  2. The tag has an attribute that references a resource from the applications resources .Note the @sympol preceding the drawable identifier. This is a hint for the file to look in the drawable folder of the applications resource for a resource called icon
  3. The tag contains the following attributes and values
    • Class represents the Java class implementing this activity
    • Android:label is the name of the application coming from one of the string resource. The string.xml file contains localizated string for the application
    • represents the IntentFilter available in the sample application. This is the most commonIntentFilter seen in Android application. This implement the entry point for the main action and is located in the launcher of the OS.
Related posts

No comments:

Post a Comment