AndroidManifest.xml标签中是否可以有自定义属性?

MM.*_*MM. 30 android android-manifest

我想将自定义属性添加到AndroidManifest.xml文件的应用程序标记中.这在Android环境中是否可行?

Sim*_*mon 63

是.这是一个例子.自定义标签是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">
Run Code Online (Sandbox Code Playgroud)

要访问它:

    ApplicationInfo ai = _context.getPackageManager().getApplicationInfo(_context.getPackageName(),PackageManager.GET_META_DATA);
    ai.metaData.get("ContentVersion")
Run Code Online (Sandbox Code Playgroud)

  • 呵呵.没有评论的downvote.这没有用!如果你回来的话,请告诉我答案有什么问题! (8认同)
  • 好的,现在2个downvotes就是一个非常好的答案.我不是为了积分,我真的不在意失去他们中的两个,我有成千上万,所以如果你愿意的话请继续下去,但请你好好告诉我为什么. (3认同)