2013年9月24日星期二

[Android] How to call the version number and displayed

Rt. . . . . . . . . . . . . . . . . . . . . . . . .
------ Solution ---------------------------------------- ----
Gets the current application version number :
   private String getVersionName() throws Exception
   {
           // 获取packagemanager的实例
           PackageManager packageManager = getPackageManager();
           // getPackageName()是你当前类的包名,0代表是获取版本信息
           PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0);
           String version = packInfo.versionName;
           return version;
   }


Gets the version number of the current system :
"Product Model: " + android.os.Build.MODEL + "," 
                + android.os.Build.VERSION.SDK + "," 
                + android.os.Build.VERSION.RELEASE

没有评论:

发表评论