모든 앱 프로젝트는 프로젝트 소스 세트의 루트에 AndroidManifest.xml 파일이 있어야 한다.
매니페스트 파일은 Android 빌드 도구, Android 운영체제 및 Google Play에 앱에 관한 필수 정보를 설명하는 역할이다.
1. manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
...
</manifest>
AndroidManifest.xml 파일의 루트 요소, 단 하나의 application 요소를 포함해야 한다.
네임스페이스를 지정해주는 xmlns:android 속성, package 속성을 지정
2. application
<application android:allowTaskReparenting=["true" | "false"]
android:allowBackup=["true" | "false"]
android:allowClearUserData=["true" | "false"]
android:allowNativeHeapPointerTagging=["true" | "false"]
android:appCategory=["accessibility" | "audio" | "game" |
"image" | "maps" | "news" | "productivity" | "social" | "video"]
android:backupAgent="string"
android:backupInForeground=["true" | "false"]
android:banner="drawable resource"
android:dataExtractionRules="string resource"
android:debuggable=["true" | "false"]
android:description="string resource"
android:enabled=["true" | "false"]
android:extractNativeLibs=["true" | "false"]
android:fullBackupContent="string"
android:fullBackupOnly=["true" | "false"]
android:gwpAsanMode=["always" | "never"]
android:hasCode=["true" | "false"]
android:hasFragileUserData=["true" | "false"]
android:hardwareAccelerated=["true" | "false"]
android:icon="drawable resource"
android:isGame=["true" | "false"]
android:killAfterRestore=["true" | "false"]
android:largeHeap=["true" | "false"]
android:label="string resource"
android:logo="drawable resource"
android:manageSpaceActivity="string"
android:name="string"
android:networkSecurityConfig="xml resource"
android:permission="string"
android:persistent=["true" | "false"]
android:process="string"
android:restoreAnyVersion=["true" | "false"]
android:requestLegacyExternalStorage=["true" | "false"]
android:requiredAccountType="string"
android:resizeableActivity=["true" | "false"]
android:restrictedAccountType="string"
android:supportsRtl=["true" | "false"]
android:taskAffinity="string"
android:testOnly=["true" | "false"]
android:theme="resource or theme"
android:uiOptions=["none" | "splitActionBarWhenNarrow"]
android:usesCleartextTraffic=["true" | "false"]
android:vmSafeMode=["true" | "false"] >
. . .
</application>
포함된 위치 : manifest
포함 가능한 요소 : activity, activity-alias, meta-data, service, receiver, profileable, provider, uses-library, uses-native-library
매니페스트 파일에는 단 하나의 application 요소를 포함해야 한다.
이 요소는 애플리케이션의 각 구성요소를 선언하고 모든 구성요소에 영향을 줄 수 있는 속성을 가진 하위 요소를 포함한다.
이 중 여러 속성(icon, label, permission, process, taskAffinity, allowTaskReparenting)이 구성요소의 해당하는 속성에 기본값을 설정, 그 외 속성(debuggable, enabled, description, allowClearUserData)은 애플리케이션의 값을 전체적으로 설정하며 구성요소별로 재정의할 수 없다.
3. activity
<activity android:allowEmbedded=["true" | "false"]
android:allowTaskReparenting=["true" | "false"]
android:alwaysRetainTaskState=["true" | "false"]
android:autoRemoveFromRecents=["true" | "false"]
android:banner="drawable resource"
android:clearTaskOnLaunch=["true" | "false"]
android:colorMode=[ "hdr" | "wideColorGamut"]
android:configChanges=["mcc", "mnc", "locale",
"touchscreen", "keyboard", "keyboardHidden",
"navigation", "screenLayout", "fontScale",
"uiMode", "orientation", "density",
"screenSize", "smallestScreenSize"]
android:directBootAware=["true" | "false"]
android:documentLaunchMode=["intoExisting" | "always" |
"none" | "never"]
android:enabled=["true" | "false"]
android:excludeFromRecents=["true" | "false"]
android:exported=["true" | "false"]
android:finishOnTaskLaunch=["true" | "false"]
android:hardwareAccelerated=["true" | "false"]
android:icon="drawable resource"
android:immersive=["true" | "false"]
android:label="string resource"
android:launchMode=["standard" | "singleTop" |
"singleTask" | "singleInstance" | "singleInstancePerTask"]
android:lockTaskMode=["normal" | "never" |
"if_whitelisted" | "always"]
android:maxRecents="integer"
android:maxAspectRatio="float"
android:multiprocess=["true" | "false"]
android:name="string"
android:noHistory=["true" | "false"]
android:parentActivityName="string"
android:persistableMode=["persistRootOnly" |
"persistAcrossReboots" | "persistNever"]
android:permission="string"
android:process="string"
android:relinquishTaskIdentity=["true" | "false"]
android:resizeableActivity=["true" | "false"]
android:screenOrientation=["unspecified" | "behind" |
"landscape" | "portrait" |
"reverseLandscape" | "reversePortrait" |
"sensorLandscape" | "sensorPortrait" |
"userLandscape" | "userPortrait" |
"sensor" | "fullSensor" | "nosensor" |
"user" | "fullUser" | "locked"]
android:showForAllUsers=["true" | "false"]
android:stateNotNeeded=["true" | "false"]
android:supportsPictureInPicture=["true" | "false"]
android:taskAffinity="string"
android:theme="resource or theme"
android:uiOptions=["none" | "splitActionBarWhenNarrow"]
android:windowSoftInputMode=["stateUnspecified",
"stateUnchanged", "stateHidden",
"stateAlwaysHidden", "stateVisible",
"stateAlwaysVisible", "adjustUnspecified",
"adjustResize", "adjustPan"] >
. . .
</activity>
포함된 위치 : application
포함 가능한 항목 : intent-filter, meta-data, layout
애플리케이션의 시각적 사용자 인터페이스 요소를 구현하는 활동(Activity 서브클래스)을 선언한다.
모든 활동은 매니페스트 파일의 activity 요소로 나타내야 한다.
여기에 선언되지 않은 활동은 시스템에 표시되지 않으며 실행되지 않는다.
4. service
<service android:description="string resource"
android:directBootAware=["true" | "false"]
android:enabled=["true" | "false"]
android:exported=["true" | "false"]
android:foregroundServiceType=["camera" | "connectedDevice" |
"dataSync" | "location" | "mediaPlayback" |
"mediaProjection" | "microphone" | "phoneCall"]
android:icon="drawable resource"
android:isolatedProcess=["true" | "false"]
android:label="string resource"
android:name="string"
android:permission="string"
android:process="string" >
. . .
</service>
포함된 위치 : application
포함 가능한 항목 : intent-filter, meta-data
안드로이드 애플리케이션을 구성하는 component 중 service를 정의한다.
Activity와 달리, 서비스는 시각적 사용자 인터페이스가 없고 오래 실행되는 백그라운드 작업이나 다른 애플리케이션에서 호출할 수 있는 리치 커뮤니케이션 API를 구현하는 데 사용한다.
모든 서비스는 매니페스트 파일의 service 요소로 나타내야 한다. 또한 activity와 마찬가지로 여기에 선언되지 않은 서비스는 시스템에 표시되지 않으며 실행되지 않는다.
5. receive
<receiver android:directBootAware=["true" | "false"]
android:enabled=["true" | "false"]
android:exported=["true" | "false"]
android:icon="drawable resource"
android:label="string resource"
android:name="string"
android:permission="string"
android:process="string" >
. . .
</receiver>
포함된 요소 : applicaion
포함 가능한 항목 : intent-filter, meta-data
안드로이드 애플리케이션을 구성하는 component 중 broadcast receiver을 정의한다.
broadcast receiver를 사용하면 애플리케이션의 다른 구성요소가 실행되고 있지 않을 때도 시스템이나 다른 애플리케이션에서 브로드캐스트팅하는 인텐트를 애플리케이션에서 수신할 수 있다.
receiver 태그 안에 intent filter을 정의하여 어떠한 브로드캐스트 메시지에 반응할지를 지정할 수 있다.
6. provider
<provider android:authorities="list"
android:directBootAware=["true" | "false"]
android:enabled=["true" | "false"]
android:exported=["true" | "false"]
android:grantUriPermissions=["true" | "false"]
android:icon="drawable resource"
android:initOrder="integer"
android:label="string resource"
android:multiprocess=["true" | "false"]
android:name="string"
android:permission="string"
android:process="string"
android:readPermission="string"
android:syncable=["true" | "false"]
android:writePermission="string" >
. . .
</provider>
포함된 요소 : application
포함 가능한 요소 : meta-data, grant-uri-permission, intent-filter, path-permission
안드로이드 애플리케이션을 구성하는 component 중 content provider 을 정의한다.
content provider는 어플리케이션 내의 데이터베이스를 다른 애플리케이션가 공유할 수 있도록 해주는 역할을 한다.
애플리케이션의 모든 content provider은 manifest 파일의 provider 요소에서 정의해야 하며 그러지 않으면 시스템에서 인식되지 않고 실행되지 않는다.
7. intent-filter
<intent-filter android:icon="drawable resource"
android:label="string resource"
android:priority="integer" >
. . .
</intent-filter>
포함된 요소 : activity, activity-alias, service, receiver, provider
포함해야 하는 요소 : action
포함 가능한 요소 : category, data
Activity, Service, Broadcast Receiver가 응답할 수 있는 인텐트의 유형을 지정한다.
인텐트 필터는 상위 구성요소의 기능, 즉 활동이나 서비스가 할 수 있는 작업과 수신기가 처리할 수 있는 브로드캐스트의 유형을 선언한다.
전달되는 유형의 수신 인텐트로 구성요소를 열고 이 구성요소에 유의미하지 않은 인텐트를 필터링한다.
8. action
<action android:name="string" />
포함된 요소 : intent-filter
intent filter에 작업을 추가한다.
intent-filter 요소에 action 요소가 하나 이상 포함되어야 하며 없으면 필터가 Intent 객체를 허용하지 않는다.
9. category
<category android:name="string" />
포함된 요소 : intent-filter
intent filter 밑에 category 요소를 정의하여 component의 유형이 무엇인지 정의할 수 있다.
10. uses-permission
<uses-permission android:name="string"
android:maxSdkVersion="integer" />
포함된 위치 : manifest
앱이 올바르게 작동하기 위해 사용자가 반드시 부여해야 하는 시스템 권한이다.
애플리케이션이 설치될 때(Android 5.1 이하 버전을 실행하는 기기) 또는 앱이 실행 중일 때(Android 6.0 이상 버전을 실행하는 기기) 사용자에게 권한이 부여된다.
액티비티(Activity)
서비스(Service)
방송 수신자 (BroadCast Receiver)
콘텐트 제공자 (Content Provider)
인텐트 (Intent)
참고
https://developer.android.com/guide/topics/manifest/manifest-intro?hl=ko#components