Android Device Version Check GetVersionName(final Context context)

Here you can find the source of GetVersionName(final Context context)

Description

Get Version Name

Declaration

public static String GetVersionName(final Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {
    public static String GetVersionName(final Context context) {
        String versionName = "1.0.0";
        PackageManager packageManager = context.getPackageManager();
        try {/*from w ww . j a  v  a 2  s .  com*/
            PackageInfo packageInfo = packageManager.getPackageInfo(
                    context.getPackageName(), 0);
            versionName = packageInfo.versionName;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return versionName;
    }
}

Related

  1. GetVersionCode(final Context con)
  2. getDefaultVendor()
  3. getPhoneVersion()
  4. isJellybeanOrLater()
  5. isJellybeanOrLater()