Книга: Beginning Android
Your Application Does Something, Right?
Your Application Does Something, Right?
The real meat of the manifest file is the children of the application
element.
By default, when you create a new Android project, you get a single activity
element:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.commonsware.android.skeleton">
<application>
<activity android:name=".Now" android:label="Now">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This element supplies android:name
for the class implementing the activity, android:label
for the display name of the activity, and (frequently) an intent-filter
child element describing under what conditions this activity will be displayed. The stock activity
element sets up your activity to appear in the launcher, so users can choose to run it. As you’ll see later in this book, you can have several activities in one project if you so choose.
You may also have one or more receiver elements indicating non-activities that should be triggered under certain conditions, such as when an SMS message comes in. These are called intent receivers and are described in Chapter 23.
You may have one or more provider elements indicating content providers — components that supply data to your activities and, with your permission, other activities in other applications on the device. These wrap up databases or other data stores into a single API that any application can use. Later you’ll see how to create content providers and how to use content providers that you or others create.
Finally, you may have one or more service elements describing services — long-running pieces of code that can operate independent of any activity. The quintessential example is the MP3 player, where you want the music to keep playing even if the user pops open other activities and the MP3 player’s user interface is “misplaced.” Chapters 30 and 31 cover how to create and use services.
- When Something Goes Wrong
- Chapter 12. Debugging your scripts
- Compiling the user-land applications
- Listing your active rule-set
- Updating and flushing your tables
- How to use this License for your documents
- 2. How to Apply These Terms to Your New Programs
- Scaling makes your object darker?
- CHAPTER 6 Productivity Applications
- Partitioning Your Hard Drive
- Available Applications
- Keeping Your Software Up-to-Date