Fields in the AndroidManifest.xml file
The following listing shows an example for the
AndroidManifest.xml
file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.vogella.android.temperature"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Convert"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>
The
package
attribute defines the base package for the
Java objects referred to in
this file. If a Java object lies within a different
package, it must
be declared with the full qualified package name.
Google Play
requires that every Android application uses its
own
unique package.
Therefore
it is a good habit to
use
your
reverse
domain
name as
package name. This
will
avoid
collisions with other
Android
applications.
android:versionName
and
android:versionCode
specify the
version of your application.
versionName
is what the user sees and
can be any String.
versionCode
must be an integer. The Android
Market determine based on the
versionCode
,
if it should perform an update of the applications for the
existing
installations.
You
typically
start
with "1" and
increase this value by
one, if
you
roll-out
a
new
version
of your
application.
The
<activity>
tag
defines an
activity component. The
name
attribute points to class, which (if not fully qualified), is
relative to the package defined in the
package
attribute.
The
intent filter
part in the Android manifest file, tells the Android runtime that
this activity should to registered as possible entry point into the
application and made available in the launcher of the Android system.
The action define that is can be started
android:name="android.intent.action.MAIN"
) and the
category android:name="android.intent.category.LAUNCHER"
category tells the Android system to add the activity to the
launcher.
The
@string/app_name
value refers to resource files which contain
the actual value of the
application name. The usage of resource file makes it easy to provide
different
resources,
e.g. strings, colors,
icons, for different devices
and makes it easy
to translate
applications.
The
uses-sdk
part of the
AndroidManifest.xml
file defines
the
minimal SDK version for which your application is
valid. This will
prevent
your application being installed on
unsupported devices.
No comments:
Post a Comment