Android Context Get getPackageVersionAsInt(Context c)

Here you can find the source of getPackageVersionAsInt(Context c)

Description

get Package Version As Int

License

Open Source License

Declaration

public static int getPackageVersionAsInt(Context c) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

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

import android.util.Log;

public class Main {
    public static int getPackageVersionAsInt(Context c) {
        int packageVersion = 0;
        try {// ww  w .j a  v  a 2s  . com
            PackageInfo pInfo = c.getPackageManager().getPackageInfo(
                    c.getPackageName(), 0);
            packageVersion = pInfo.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            Log.e("getPackageVersion",
                    "Unable to read PackageName in RegisterApp");
            e.printStackTrace();
        }
        return packageVersion;
    }
}

Related

  1. getOffset(Context context)
  2. getOpenGLESVersion(final Context context)
  3. getOrientation(Context context, Uri photoUri)
  4. getPackageName(final Context context)
  5. getPackageVersion(Context c)
  6. getPath(Context context, Uri uri)
  7. getPathFromUri(Context context, Uri uri)
  8. getPermissionLabel(Context context, String permission)
  9. getPreferences(Context context, String campaignUrn)