2012年7月31日 星期二

android get apk version

// use to get this apk version which write in its own AndroidManifest.xml
    protected String getVersion() {
        PackageInfo pInfo = null;
        try {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            return "";
        }
        return pInfo.versionName;
    }

沒有留言:

張貼留言