标签:
(转自:http://www.cnblogs.com/qsl568/archive/2012/03/14/2395636.html)
获取当前应用的版本号:
private String getVersionName() throws Exception { // 获取packagemanager的实例 PackageManager packageManager = getPackageManager(); // getPackageName()是你当前类的包名,0代表是获取版本信息 PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0); String versionName = packInfo.versionName; String versionCode = packInfo.versionCode; return version; }
获取当前系统的版本号:
1 textView.setText("Product Model: " + android.os.Build.MODEL + "," 2 + android.os.Build.VERSION.SDK + "," 3 + android.os.Build.VERSION.RELEASE);
或:
1 /* 2 * 3 * Build.VERSION_CODES 4 1 (0x00000001) Android 1.0 BASE 5 2 (0x00000002) Android 1.1 BASE_1_1 6 3 (0x00000003) Android 1.5 CUPCAKE 7 4 (0x00000004) Android 1.6 DONUT 8 5 (0x00000005) Android 2.0 ECLAIR 9 6 (0x00000006) Android 2.0.1 ECLAIR_0_1 10 7 (0x00000007) Android 2.1 ECLAIR_MR1 11 8 (0x00000008) Android 2.2 FROYO 12 9 (0x00000009) Android 2.3 GINGERBREAD 13 10 (0x0000000a) Android 2.3.3 GINGERBREAD_MR1 14 11 (0x0000000b) Android 3.0 HONEYCOMB 15 12 (0x0000000c) Android 3.1 HONEYCOMB_MR1 16 13 (0x0000000d) Android 3.2 HONEYCOMB_MR2*/ 17 /*获取当前系统的android版本号*/ 18 int currentapiVersion=android.os.Build.VERSION.SDK_INT;
android 获取应用的当前版本号&获取当前android系统的版本号
标签:
原文地址:http://www.cnblogs.com/jenson138/p/4444193.html