Example usage for android.app Activity getPackageManager

List of usage examples for android.app Activity getPackageManager

Introduction

In this page you can find the example usage for android.app Activity getPackageManager.

Prototype

@Override
    public PackageManager getPackageManager() 

Source Link

Usage

From source file:Main.java

public static String getInstallerPackageName(String pname, Activity form) {
    return form.getPackageManager().getInstallerPackageName(pname);
}

From source file:Main.java

public static boolean isCameraHardwareAvailable(Activity currentActivity) {
    return currentActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
}

From source file:Main.java

public static String getPackageName(Activity instance) {
    PackageManager pManager = instance.getPackageManager();
    return pManager.getApplicationLabel(instance.getApplicationInfo()).toString();
}

From source file:Main.java

public static boolean hasMicrophone(Activity activity) {
    PackageManager packageManager = activity.getPackageManager();
    return packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE);
}

From source file:Main.java

public static void launch(Activity activity, String packageName) {
    Intent intent = activity.getPackageManager().getLaunchIntentForPackage(packageName);
    if (null != intent) {
        activity.startActivity(intent);/*from   w  w  w  .ja  v a2 s.  c o  m*/
    }
}

From source file:Main.java

public static String getVersionName(Activity ctx) {
    PackageManager packageManager = ctx.getPackageManager();
    PackageInfo packInfo = null;/*  www . jav a 2s.  c o m*/
    try {
        packInfo = packageManager.getPackageInfo(ctx.getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    String version = packInfo.versionName;
    return version;
}

From source file:Main.java

public static boolean btleSupport(final Activity activity) {
    return activity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
}

From source file:Main.java

public static boolean hasCamera(Activity activity) {
    PackageManager packageManager = activity.getPackageManager();
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

From source file:Main.java

public static String getAppName(Activity activity) {
    return activity.getApplicationInfo().loadLabel(activity.getPackageManager()).toString();
}

From source file:Main.java

public static String getActivityMetaData(Activity activity, String key) {
    try {/*from   w ww. ja va2  s. c o m*/
        return activity.getPackageManager().getActivityInfo(activity.getComponentName(),
                PackageManager.GET_META_DATA).metaData.getString(key);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}