Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have custom attributes in AndroidManifest.xml tags?

I would like to add a custom attribute to the application tag of my AndroidManifest.xml file. Is this possible in the Android environment?

like image 564
MM. Avatar asked Apr 25 '12 08:04

MM.


People also ask

What does AndroidManifest xml contain?

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.

Which attribute in the AndroidManifest xml is used to give the app name?

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.

Which tag is used for custom formation in manifest file?

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.


2 Answers

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") 
like image 81
Simon Avatar answered Sep 21 '22 06:09

Simon


You cannot define custom attribute to a predefined tag, but you can add key-value pairs called meta-data.

like image 23
waqaslam Avatar answered Sep 20 '22 06:09

waqaslam