Книга: 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"
  <activity android:name=".Now" android:label="Now">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />

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.

Оглавление книги

Генерация: 0.461. Запросов К БД/Cache: 3 / 0
Вверх Вниз