赞
踩
- android {
- buildTypes {
- release {
- manifestPlaceholders = [
- "Key" : "Release_Key",
- ]
- ...
- }
-
- debug {
- manifestPlaceholders = [
- "Key" : "debug_Key",
- ]
- ...
- }
- }
- }
其中,Key就是自定义的一个键,值根据业务需要配置。
- <application
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
- android:roundIcon="@mipmap/ic_launcher_round"
- android:supportsRtl="true"
- android:theme="@style/AppTheme">
- <activity android:name=".MainActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <meta-data android:name="Key" android:value="${Key}"/>
-
- </application>
- String Key;
- try {
- ApplicationInfo appInfo = getPackageManager()
- .getApplicationInfo(getPackageName(),PackageManager.GET_META_DATA);
-
- Key = appInfo.metaData.getString("Key");
-
- tv.setText("-------------Key:" + Key);
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
-
- }
release包效果:
debug包效果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。