Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add user defined properties/values in to the Android manifest file?

I want to add a custom attribute / property into the manifest file, and be able to read it at run time. I want to do this so I can customize the app's behavior via these manifest properties. How can this be done?

like image 559
inor Avatar asked Oct 28 '11 10:10

inor


People also ask

What information would be contained in the Android manifest file?

The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

Where is the Android manifest file?

The file is located at WorkspaceName>/temp/<AppName>/build/luaandroid/dist. The manifest file provides essential information about your app to the Android operating system, and Google Play store. The Android manifest file helps to declare the permissions that an app must have to access data from other apps.

How do I set permissions in Android manifest?

In Eclipse we were able to add permissions in AndroidManifest. xml by going to AndroidManifest. xml->Permission-> Adding permissions.


1 Answers

You can add meta-data to your AndroidManifest.xml file and then read that in your application.

Write the data like so:

<meta-data android:value="bar" android:name="foo"></meta-data> 

And read the data like so:

ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Object value = (Object)ai.metaData.get("foo"); 

See http://developer.android.com/guide/topics/manifest/meta-data-element.html

like image 154
P.Melch Avatar answered Oct 10 '22 14:10

P.Melch