Example usage for android.content.pm PackageManager GET_CONFIGURATIONS

List of usage examples for android.content.pm PackageManager GET_CONFIGURATIONS

Introduction

In this page you can find the example usage for android.content.pm PackageManager GET_CONFIGURATIONS.

Prototype

int GET_CONFIGURATIONS

To view the source code for android.content.pm PackageManager GET_CONFIGURATIONS.

Click Source Link

Document

PackageInfo flag: return information about hardware preferences in PackageInfo#configPreferences PackageInfo.configPreferences , and requested features in PackageInfo#reqFeatures and PackageInfo#featureGroups .

Usage

From source file:Main.java

public static String getCurrentVersion(Context c) {
    String pkgName = c.getPackageName();
    try {//from www  .j  av  a  2  s  . c om
        PackageInfo pinfo = c.getPackageManager().getPackageInfo(pkgName, PackageManager.GET_CONFIGURATIONS);
        return pinfo.versionName;
    } catch (Exception e) {
    }
    return "";
}

From source file:Main.java

public static boolean isMIUIRom(final Context context) {
    try {//from   w  ww  . j a v a  2 s  . c o m
        return context.getPackageManager().getPackageInfo("com.miui.cloudservice",
                PackageManager.GET_CONFIGURATIONS) != null;
    } catch (final NameNotFoundException e) {
        return false;
    }
}

From source file:Main.java

public static int getAppVerCode(Context ctx) {
    try {/* ww  w . ja v a  2s. c  om*/
        PackageInfo info = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        return info.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return 0;
    }
}

From source file:Main.java

public static String getAppVerName(Context ctx) {
    try {/*from  ww w.j  ava 2s. com*/
        PackageInfo info = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        return info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

private static PackageInfo getPackageInfo(Context context) {
    PackageInfo pi = null;/*from  ww  w .  j  a  v  a  2s  .  co m*/

    try {
        PackageManager pm = context.getPackageManager();
        pi = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS);

        return pi;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return pi;
}

From source file:Main.java

public static String getSDKVersion(Context context) {
    PackageManager pm = context.getPackageManager();
    String pkgName = context.getPackageName();
    PackageInfo pkgInfo = null;//  w  w  w  .  jav  a 2s.c om
    String ret = "";
    try {
        pkgInfo = pm.getPackageInfo(pkgName, PackageManager.GET_CONFIGURATIONS);
        ret = pkgInfo.versionName;
    } catch (NameNotFoundException ex) {

    }
    return ret;
}

From source file:Main.java

public static int getVersionCode(Context applicationContext) {
    try {/*from w w  w.  j  a  va  2 s. c o m*/
        PackageManager pm = applicationContext.getPackageManager();
        PackageInfo pi = pm.getPackageInfo(applicationContext.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        return pi.versionCode;
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return 0;
    }
}

From source file:Main.java

public static String getVersionName(Context applicationContext) {
    try {//  ww  w.  j av  a2  s . c  o  m
        PackageManager pm = applicationContext.getPackageManager();
        PackageInfo pi = pm.getPackageInfo(applicationContext.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
        return pi.versionName;
    } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static PackageInfo getPackageInfo(Context context) {
    PackageInfo packageInfo = null;//w w  w.  ja va 2 s. c o  m

    try {
        PackageManager pm = context.getPackageManager();
        packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS);

        return packageInfo;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return packageInfo;
}

From source file:Main.java

public static PackageInfo getPackageInfo(Context context) {
    try {/*from  w  ww. j a v  a  2 s .c o  m*/
        return context.getPackageManager().getPackageInfo(context.getPackageName(),
                PackageManager.GET_CONFIGURATIONS);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}