Hardware Reference
In-Depth Information
AndroidManifest.xml
The manifest file is the best place to start when developing applications, because it is the entry point for every Android
application. The manifest is fairly consistent between applications and can be reused with minor changes across
many different applications. The first line defines the XML version and the encoding, and will be the same in all the
XML files. The tags following define the systems resources, package name, versions, main icon, application name,
and activity to be used in the application. The package name has to match that of the first Java container that contains
the code for the project to tell the operating system where to look, and the activity name has to match that of the first
activity that will be run. Also, the entry point to an app is the constructor for the main activity class. The rest of the
manifest file defines what needs to be done when the application is started either by the user or a system event, as well
as any extra libraries on the system that the application needs.
This application is an activity-based program and has a user interface when started (alternatively, applications
can be started as a process to run in the background and can have no user interface). Replace the original
AndroidManifest.xml file with Listing 4-2; to make things easier, make sure that the package attribute and
<activity> tag match those of the original code generated.
Listing 4-2. AndroidManifest.xml Replacing the Autogenerated Original
<?xml version= "1.0" encoding= "utf-8" ?>
<!-- define entry package name, name space and code version -->
<manifest xmlns:android= " http://schemas.android.com/apk/res/android "
package= "CH4.example.proArduino" android:versionCode= "1"
android:versionName= "1.0" >
<!-- define minimum usable android version-->
<uses-sdk android:minSdkVersion= "10" />
<!-- application's definitions icons, name and entry activity -->
<application android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" >
<!-- activity to be launched when program starts -->
<activity android:name= ".CH4ExamplesActivity" android:label= "@string/app_name" >
<!-- define events that this app responds to -->
<intent-filter>
<action android:name= "android.intent.action.MAIN" />
<category android:name= "android.intent.category.LAUNCHER" />
</intent-filter>
<!-- respond when attaching accessories -->
<intent-filter>
<action android:name= "android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
</intent-filter>
<!-- use listed file to determine if accessory is for this application -->
<meta-data android:name= "android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
android:resource= "@xml/accessory_filter" />
</activity>
<!-- ADK programs need this library -->
<uses-library android:name= "com.android.future.usb.accessory" ></uses-library>
</application>
</manifest>
<!-- end of AndroidManifest.xml -->
 
Search WWH ::




Custom Search