2012-10-25

Add custom attributes into AndroidManifest.xml

If you want to add attributes into AndroidManifest.xml, you need to add tag <meta-data /> inside your <application />
EX:

<application android:name=".ExampleApplication"
             android:icon="@drawable/icon"
             android:label="@string/app_name">
    <meta-data android:name="CustomValue"
                 android:value="1.0.0" />
    <activity android:name="com.example.MainActivity"
              ...
And get value by:
ApplicationInfo appInfo = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
String value = (String) appInfo.metaData.get("CustomValue");

No comments: