Android Device Version Check GetVersionCode(final Context con)

Here you can find the source of GetVersionCode(final Context con)

Description

Get Version Code

Declaration

public static int GetVersionCode(final Context con) 

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 int GetVersionCode(final Context con) {
        int version = 1;
        PackageManager packageManager = con.getPackageManager();
        try {//from   ww  w .java 2 s  . c o m
            PackageInfo packageInfo = packageManager.getPackageInfo(
                    con.getPackageName(), 0);
            version = packageInfo.versionCode;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return version;
    }
}

Related

  1. GetVersionName(final Context context)
  2. getDefaultVendor()
  3. getPhoneVersion()
  4. isJellybeanOrLater()