Format AndroidManifest.xml — Permissions, Activities, and Intents
Format and organize Android AndroidManifest.xml files. Understand the manifest structure, permission declarations, activity/service/receiver components, and intent filter configuration.
Detailed Explanation
Formatting AndroidManifest.xml
The AndroidManifest.xml is the essential configuration file for every Android application. It declares the app's components, permissions, hardware requirements, and more. A well-formatted manifest is critical for understanding an app's capabilities.
Manifest Structure
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".MyService" />
<receiver android:name=".MyReceiver" />
</application>
</manifest>
Permission Declarations
Permissions should be listed before the <application> element, grouped by category:
- Network:
INTERNET,ACCESS_NETWORK_STATE - Storage:
READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE - Hardware:
CAMERA,RECORD_AUDIO,ACCESS_FINE_LOCATION - System:
RECEIVE_BOOT_COMPLETED,VIBRATE
Component Organization
Within <application>, organize components in this order for consistency:
- Activities — UI screens
- Services — background operations
- Receivers — broadcast receivers
- Providers — content providers
- Meta-data — additional configuration
Intent Filters
Intent filters declare what implicit intents a component can handle. Proper indentation makes the action, category, and data elements visually clear:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="example.com"
android:pathPrefix="/link" />
</intent-filter>
Android Namespace
All Android-specific attributes use the android: namespace prefix. Formatting ensures these namespace-prefixed attributes are clearly visible and consistently aligned.
Use Case
Android manifest formatting is essential for mobile developers reviewing permission changes in code reviews, debugging intent resolution issues, preparing apps for Google Play submission (which validates manifest structure), and auditing third-party SDK permissions added through manifest merging.
Try It — XML Formatter
Related Topics
Format Maven POM.xml — Dependencies, Plugins, and Profiles
Configuration
Format Spring Framework XML Configuration Files
Configuration
XML Namespace Validation — Prefixes, URIs, and Scope
Validation
XML Indentation Styles — Spaces, Tabs, and Depth Control
Basic Formatting
Format and Pretty-Print XML Online
Basic Formatting