I would like to add a custom attribute to the application tag of my AndroidManifest.xml file. Is this possible in the Android environment?
Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
Also, the versionName attribute is used to specify a public version that will be displayed to the users. We can also specify whether our app should install on an SD card of the internal memory using the installLocation attribute. A typical manifest node looks as: XML.
Element Tags of Manifest File in Android<manifest> – Manifest tag is the root tag and specifies the package name for your application. 2. <application> – The application is the subpart of the Manifest tag, and its job is to specify the general information about the applications such as: Icon.
Yes. Here's an example. The custom tag is ContentVersion
.
<application android:name=".MyApplication" android:icon="@drawable/icon" android:label="@string/app_name"> <meta-data android:name="ContentVersion" android:value="1.9" /> <activity android:name="com.someone.something.MainActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:screenOrientation="sensor" android:label="@string/app_name">
To access it:
ApplicationInfo ai = _context.getPackageManager().getApplicationInfo(_context.getPackageName(),PackageManager.GET_META_DATA); ai.metaData.get("ContentVersion")
You cannot define custom attribute to a predefined tag, but you can add key-value pairs called meta-data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With