Created
November 5, 2014 01:50
-
-
Save jimbray/71cbcaf2508735e13374 to your computer and use it in GitHub Desktop.
获取Android程序版本号
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String getCurVersionName(Context context) { | |
| String versionName = null; | |
| try { | |
| PackageInfo pInfo = context.getPackageManager().getPackageInfo( | |
| context.getPackageName(), 0); | |
| versionName = pInfo.versionName; | |
| } catch (NameNotFoundException e) { | |
| versionName = "没有版本号"; | |
| } | |
| return versionName; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment