Android APK Version Get getAppVersionName(Context context, String defVersion)

Here you can find the source of getAppVersionName(Context context, String defVersion)

Description

get App Version Name

License

Open Source License

Declaration

public static String getAppVersionName(Context context,
            String defVersion) 

Method Source Code

//License from project: Open Source License 

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.WindowManager;
import android.webkit.URLUtil;

public class Main{
    static final String TAG = AndroidUtil.class.getSimpleName();
    public static String getAppVersionName(Context context,
            String defVersion) {/* www . j a  v  a2 s  . co m*/
        String versionName = defVersion;
        try {
            // ---get the package info---
            PackageManager pm = context.getPackageManager();
            PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
            versionName = pi.versionName;
            if (versionName == null || versionName.length() <= 0) {
                return defVersion;
            }
        } catch (Exception e) {
            FrameworkLog.e(TAG,
                    "getAppVersionName Exception: " + e.getMessage());
        }
        return versionName;
    }
}

Related

  1. getAPKVersion(Context context)
  2. getAppVer(Context context)
  3. getAppVersionCode(Context context)
  4. getAppVersionCode(Context context)
  5. getAppVersionName(Context context)
  6. getApplicationVersion(Context ctx)
  7. getFirstInstalled()
  8. getVersion(Context context)
  9. getVersionCode(Context context)