Example usage for android.content.pm PackageManager getPackageArchiveInfo

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

Introduction

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

Prototype

public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) 

Source Link

Document

Retrieve overall information about an application package defined in a package archive file

Usage

From source file:Main.java

public static PackageInfo getPackageInfo(Context context, String archiveFilePath) {
    PackageManager pm = context.getPackageManager();
    return pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_ACTIVITIES);
}

From source file:Main.java

public static PackageInfo getUninatllAppInfo(PackageManager pm, String archiveFilePath) {
    PackageInfo info = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_ACTIVITIES);
    return info;/* ww w  .  ja v  a2 s.  c o  m*/
}

From source file:Main.java

public static boolean checkAPKState(Context context, String path) {
    PackageInfo pi = null;//from   w  ww .  ja v  a  2 s  .co  m
    try {
        PackageManager pm = context.getPackageManager();
        pi = pm.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES);
        return pi == null ? false : true;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static boolean isAPKFileValid(String path, Context context) {
    PackageManager pm = context.getPackageManager();
    PackageInfo pi = pm.getPackageArchiveInfo(path, 0);

    return pi != null;
}

From source file:Main.java

public static PackageInfo getPackageInfo(String path, Context context) {
    PackageManager pm = context.getPackageManager();
    PackageInfo pi = pm.getPackageArchiveInfo(path, 0);

    pi.applicationInfo.sourceDir = path;
    pi.applicationInfo.publicSourceDir = path;
    return pi;/* w w w  . ja v  a2 s . c  om*/
}

From source file:Main.java

public static PackageInfo getApkInfo(Context context, String archiveFilePath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo apkInfo = pm.getPackageArchiveInfo(archiveFilePath, 128);
    return apkInfo;
}

From source file:Main.java

public static PackageInfo getApkInfo(Context context, String archiveFilePath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo apkInfo = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_META_DATA);
    return apkInfo;
}

From source file:Main.java

public static String getApkFilePackage(Context context, File apkFile) {
    PackageManager pm = context.getPackageManager();
    PackageInfo info = pm.getPackageArchiveInfo(apkFile.getPath(), PackageManager.GET_ACTIVITIES);
    if (info != null) {
        return info.applicationInfo.packageName;
    }//from  w  ww.  j a v a  2 s  .co  m
    return null;
}

From source file:Main.java

private static PackageInfo getApkInfo(Context context, String path) {
    PackageManager pm = context.getPackageManager();
    PackageInfo info = pm.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES);
    if (info != null) {
        return info;
    }// ww w  .  jav  a2s  .  co m
    return null;
}

From source file:Main.java

public static int getUninatllApkInfo(Context context, String archiveFilePath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo info = pm.getPackageArchiveInfo(archiveFilePath, PackageManager.GET_ACTIVITIES);
    if (info != null) {
        return info.versionCode;
    }/*  w  ww.j  a va  2s. c  o  m*/
    return -1;
}