packagemanager pm = getPackageManager();
PackageInfo pinfo = pm.getPackageInfo(gerPackageName(), PackageManager.GET_CONFIGURATIONS);
String versionCode = pinfo.versionName;
Strint versionName = pinfo.versionCode;
} catch (NameNotFoundException e) {
try {
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.csdn.xxxx"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".xxxx"
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="8"/>
</manifest>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.csdn.xxxx"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".xxxx"
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="8"/>
</manifest>