由网友(憚純De緈諨)分享简介:我想添加自定义属性/属性到清单文件,并能够在运行时读取它。我想这样做,这样我就可以通过这些表现属性自定义应用程序的行为。如何才能做到这一点?I want to add a custom attribute / property into the manifest file, and be able to read i...
我想添加自定义属性/属性到清单文件,并能够在运行时读取它。我想这样做,这样我就可以通过这些表现属性自定义应用程序的行为。如何才能做到这一点?
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?
推荐答案
可以的元数据添加到您的的AndroidManifest.xml
文件,然后读取您的应用程序。
You can add meta-data to your AndroidManifest.xml
file and then read that in your application.
将数据写入像这样:
<meta-data android:value="bar" android:name="foo"></meta-data>
和读取数据,像这样:
ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
Object value = (Object)ai.metaData.get("foo");
请参阅http://developer.android.com/guide/topics/manifest/meta-data-element.html
相关推荐
最新文章