Android 获取AndroidManifest.xml文件versionCode,versionName属性
Android 获取AndroidManifest.xml文件versionCode,versionName属性
AndroidManifest.xml文件如下
- 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>