我想在我的 AndroidManifest.xml 文件的应用程序标签中添加一个自定义属性。这在Android环境中可能吗?
问问题
12047 次
5 回答
69
是的。这是一个例子。自定义标签是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">
要访问它:
ApplicationInfo ai = _context.getPackageManager().getApplicationInfo(_context.getPackageName(),PackageManager.GET_META_DATA);
ai.metaData.get("ContentVersion")
于 2012-04-25T08:27:17.687 回答
3
于 2012-04-25T08:24:13.003 回答
0
您可以选择SharedPreferences,而不是(又名设置)。
于 2012-04-25T08:20:37.433 回答
0
在标签(以及服务和接收者)中,您可以使用标签(http://developer.android.com/guide/topics/manifest/meta-data-element.html)
它包含名称和值或资源 ID。
您可以通过 PackageManager 检索它。
于 2012-04-25T08:24:40.180 回答
-2
如果有人需要 Xamarin(Android 的 Mono)我找不到常量,但我找到了它的值,即 128。
我使用“for”条件遍历从 0 到 1000 的所有值,并检查 MetaData 属性是否为空。哈哈
于 2012-10-26T13:55:04.710 回答