Game Development Reference
In-Depth Information
The <manifest> Element
The <manifest> tag is the root element of an AndroidManifest.xml file. Here's a basic example:
<manifest xmlns:android=" http://schemas.android.com/apk/res/android "
package=" com.helloworld "
android:versionCode=" 1 "
android:versionName=" 1.0 "
android:installLocation=" preferExternal ">
...
</manifest>
We are assuming that you have worked with XML before, so you should be familiar with the first
line. The <manifest> tag specifies a namespace called android , which is used throughout the
rest of the manifest file. The package attribute defines the root package name of our application.
Later on, we'll reference specific classes of our application relative to this package name.
The versionCode and versionName attributes specify the version of our application in two forms.
The versionCode attribute is an integer that we have to increment each time we publish a new
version of our application. It is used by Google Play to track our application's version. The
versionName attribute is displayed to users of Google Play when they browse our application.
We can use any string we like here.
The installLocation attribute is only available to us if we set the build target of our Android project
in Eclipse to Android 2.2 or newer. It specifies where our application should be installed. The string
preferExternal tells the system that we'd like our application to be installed to the SD card. This
will only work on Android 2.2 or newer, and this string is ignored by all earlier Android applications.
On Android 2.2 or newer, the application will always get installed to internal storage where possible.
All attributes of the XML elements in a manifest file are generally prefixed with the android
namespace, as shown previously. For brevity, we will not specify the namespace in the following
sections when talking about a specific attribute.
Inside the <manifest> element, we then define the application's components, permissions,
hardware profiles, and supported Android versions.
The <application> Element
As in the case of the <manifest> element, let's discuss the <application> element in the form of
an example:
<application android:icon="@ drawable/icon " android:label="@ string/app_name ">
...
</application>
Now doesn't this look a bit strange? What's up with the @drawable/icon and @string/app_name
strings? When developing a standard Android application, we usually write a lot of XML files,
where each defines a specific portion of our application. Full definition of those portions requires
that we are also able to reference resources that are not defined in the XML file, such as images
or internationalized strings. These resources are located in subfolders of the res/ folder, as
discussed in Chapter 2 when we dissected the Hello World project in Eclipse.
 
Search WWH ::




Custom Search