1. Activity
2. Service
3. Content Provider
4. Intents
5. Broadcast Receiver
6. Notifications
이 구성요소들을 정의,나열하고 그 메타 데이터들을 주는것이 Manifest 파일의 역할이다.
파일은 각각의 위에 나열된 구성요소에 대한 노드를 가지고 있고 그 내부에 이름들과 그 연결이 정의된다. 또한 사용 아이콘, 현 버젼정보, 프로그램 이름과 인텐트들이 어떻게 넘겨지는지에 대한 정보도 정의될수있다.
시작노드는 manifest로 시작된다.
그 내부에 application노드에서 메타데이터들이 지정되고, 타이틀, 아이콘, 테마 들이 정의된다.
application 노드는 한 manifest에 한개밖에 지정할수 밖에 없는데 이는 또한 다른 어플리케이션 구성요소들이 정의되는 노드의 기반이 된다. 이 내부에는 Activity노드나 Provider 노드. Receiver, Permission등의 노드들이 위치한다.
예로 안드로이드 폰에 기본으로 달려나오는 알람시계의 Manifest 를 보자.
맨 먼저볼것은 큰 노드의 구성이다.
위에 user-permission 부분이
아래에 application 노드가 있다.
application 의 내부에는 1개의 콘텐트제공자, 6개의 액티비티, 3개의 리시버, 1개의 서비스가 달려있음을 본다.
그러면, 프로그램을 시작하면 제일먼저 시작되는 액티비티는 무엇인가?
AlarmClock 이다. action.MAIN, category.DEFAULT, category.LAUNCHER 가 인텐트 필터에 달려있다.
이외에도 프로그램의 distribution 을 어느 안드로이드 버젼으로, 어느 화면 사이즈의 기기로 제한할것인가에 관련된 속성도 주는 것이 가능하다.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.alarmclock"> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <application android:label="@string/app_label" android:icon="@drawable/ic_launcher_alarmclock"> <provider android:name="AlarmProvider" android:authorities="com.android.alarmclock" /> <activity android:name="AlarmClock" android:label="@string/app_label" android:icon="@drawable/ic_widget_analog_clock" android:configChanges="orientation|keyboardHidden|keyboard|navigation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="SettingsActivity" android:label="@string/settings"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name="SetAlarm" android:label="@string/set_alarm" android:configChanges="orientation|keyboardHidden|keyboard|navigation" /> <activity android:name="AlarmAlert" android:excludeFromRecents="true" android:theme="@style/alarm_alert" android:launchMode="singleInstance" android:taskAffinity="" android:configChanges="orientation|keyboardHidden|keyboard|navigation"/> <!-- This activity is basically the same as AlarmAlert but with a more generic theme. It also shows as full screen (with status bar) but with the wallpaper background. --> <activity android:name="AlarmAlertFullScreen" android:excludeFromRecents="true" android:theme="@android:style/Theme.Wallpaper.NoTitleBar" android:launchMode="singleInstance" android:taskAffinity="" android:configChanges="orientation|keyboardHidden|keyboard|navigation"/> <activity android:name="ClockPicker" /> <receiver android:name="AlarmReceiver"> <intent-filter> <action android:name="com.android.alarmclock.ALARM_ALERT" /> <action android:name="alarm_killed" /> <action android:name="cancel_snooze" /> </intent-filter> </receiver> <!-- This service receives the same intent as AlarmReceiver but it does not respond to the same broadcast. The AlarmReceiver will receive the alert broadcast and will start this service with the same intent. The service plays the alarm alert and vibrates the device. This allows the alert to continue playing even if another activity causes the AlarmAlert activity to pause. --> <service android:name="AlarmKlaxon"> <intent-filter> <action android:name="com.android.alarmclock.ALARM_ALERT" /> </intent-filter> </service> <receiver android:name="AlarmInitReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.TIME_SET" /> <action android:name="android.intent.action.TIMEZONE_CHANGED" /> </intent-filter> </receiver> <receiver android:name="AnalogAppWidgetProvider" android:label="@string/analog_gadget" android:icon="@drawable/ic_widget_analog_clock"> <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/analog_appwidget" /> </receiver> </application> </manifest>
참고로 위 Manifest 의 출처는
http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=tree
이다.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.