Android 获取AndroidManifest.xml文件versionCode,versionName属性
-
String pName = "cn.nedu.math.ninebox";
-
try {
- PackageInfo pinfo = getPackageManager().getPackageInfo(pName, PackageManager.GET_CONFIGURATIONS);
- String versionCode = pinfo.versionName;
- Strint versionName = pinfo.versionCode;
- } catch (NameNotFoundException e) {
- }
AndroidManifest.xml文件如下
-
<?xml version="1.0" encoding="utf-8"?>
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="cn.nedu.math.ninebox"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".NineBox"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
- <uses-sdk android:minSdkVersion="3" />
-
</manifest>
相关文章:
-
2021-08-13
-
2021-07-28
-
2022-12-23
-
2021-10-21
-
2021-06-19