Example usage for android.content Context getPackageManager

List of usage examples for android.content Context getPackageManager

Introduction

In this page you can find the example usage for android.content Context getPackageManager.

Prototype

public abstract PackageManager getPackageManager();

Source Link

Document

Return PackageManager instance to find global package information.

Usage

From source file:Main.java

public static void OpenApp(Context context, String pkName) {
    Intent intent = context.getPackageManager().getLaunchIntentForPackage(pkName);
    context.startActivity(intent);//  www  .  j a v a  2 s .c o m
}

From source file:Main.java

public static void runPackge(Context context, String pkg) {
    context.startActivity(context.getPackageManager().getLaunchIntentForPackage(pkg));
}

From source file:Main.java

public static boolean isFrontCameraSupported(Context ctx) {
    PackageManager pm = ctx.getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
}

From source file:Main.java

public static int getVersionApp(Context context) {
    try {/*  www  .  j  a v  a  2  s  . c o  m*/
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        return 0;
    }
}

From source file:Main.java

public static boolean isBackCameraSupported(Context ctx) {
    PackageManager pm = ctx.getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
}

From source file:Main.java

public static String getVerName(Context context) {
    try {/* w  ww. ja  v  a  2s.  c  o  m*/
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
    }
    return "";
}

From source file:Main.java

public static String getVersionName(Context context) {
    try {/*from   w  w w.  ja v a2  s. c o  m*/
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        return null;
    }
}

From source file:Main.java

public static int getVersionCode(Context con) {
    PackageManager pm = con.getPackageManager();
    PackageInfo pi = null;//from  ww  w  .j  av  a 2s  .  c  o m
    try {
        pi = pm.getPackageInfo(con.getPackageName(), 0);
        return pi.versionCode;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return 0;
    }
}

From source file:Main.java

public static String getAppVersion(Context context) {
    try {//from  w  ww. j  av a 2s.c  o m
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        return "";
    }
}

From source file:Main.java

static String VersionName(Context context) {
    try {//from ww  w.  jav  a 2 s .c  o  m
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        return "Unknown";
    }
}