PackageManager getInstallerPackageName - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager getInstallerPackageName method.

This code example shows how to use the following methods:getInstallerPackageName
		return match;
	} 
 
	public boolean isInstalledFromMarket(String pkgName)
			throws NameNotFoundException { 
		String installerPkg = pkgMngr.getInstallerPackageName(pkgName);
		boolean installedFromMarket = "com.google.android.feedback"
				.equals(installerPkg);
		return installedFromMarket;
	} 
 
	public long getClassesDexCrc() { 
		ZipFile zf;
		try { 
			zf = new ZipFile(ctx.getPackageCodePath());
		} catch (IOException e) {
			L.e(e);
			return -1; 
		} 
		ZipEntry ze = zf.getEntry("classes.dex");
6
CodeRank
This code example shows how to use the following methods:getInstallerPackageName
	} 
 
	public static boolean hasMarketLink(Context context, String packageName) {
		try { 
			PackageManager pm = context.getPackageManager();
			String installer = pm.getInstallerPackageName(packageName);
			if (installer != null)
				return installer.equals("com.android.vending") || installer.contains("google");
		} catch (Exception ex) {
			log(null, Log.WARN, ex.toString());
		} 
		return false; 
	} 
 
	private static byte[] hex2bytes(String hex) {
		// Convert hex string to byte array 
		int len = hex.length();
		byte[] result = new byte[len / 2];
		for (int i = 0; i < len; i += 2)
			result[i / 2] = (byte) ((Character.digit(hex.charAt(i), 16) << 4) + Character.digit(hex.charAt(i + 1), 16));
6
CodeRank
This code example shows how to use the following methods:getInstallerPackageName
    } 
 
    public static boolean installedFromGoogle(String packageName) {
        String pin = null;
        try { 
            pin = myPackageManager.getInstallerPackageName(packageName);
        } catch (Exception e) { } // gets IllegalArgumentException: Unknown package: ... if not installed.
 
        return pin != null && pin.equals("com.android.vending");
    } 
 
    // may be useful sometimes 
    public static PackageManager getPackageManager() {
        return myPackageManager;
    } 
 
    public static String getPackageName() {
        return myPackageName;
    } 
 
4
CodeRank
This code example shows how to use the following methods:getInstallerPackageName
	public static void appLaunched(Context ctx) {
		try { 
			// Don't even bother if not installed from Google Play 
			PackageManager pm = ctx.getPackageManager();
			String pn = ctx.getPackageName();
			String inst = pm.getInstallerPackageName(pn);
			if (inst == null || !(inst.startsWith("com.google")
					|| inst.startsWith("com.android"))) {
				return; 
			} 
		} 
		catch (Exception exp) {
			Log.w("AppRater",exp);
			// Just bailout. Don't even try recovery. 
			return; 
		} 
 
		SharedPreferences prefs = ctx.getSharedPreferences(PREFSFILE, 0);
		if (prefs.getBoolean("dontshowagain", false)) {
			return; 
4
CodeRank
This code example shows how to use the following methods:getInstallerPackageName
        return wrapped.getPackageArchiveInfo(archiveFilePath, flags);
    } 
 
    @Override 
    public String getInstallerPackageName(String packageName) {
        return wrapped.getInstallerPackageName(packageName);
    } 
 
    @Override 
    public void addPackageToPreferred(String packageName) {
        wrapped.addPackageToPreferred(packageName);
    } 
 
    @Override 
    public void removePackageFromPreferred(String packageName) {
        wrapped.removePackageFromPreferred(packageName);
    } 
 
    @Override 
    public List<PackageInfo> getPreferredPackages(int flags) {
4
CodeRank

Related PackageManager getInstallerPackageName Questions & Answers:

getInstallerPackageName Method Overview
Retrieve the package name of the application that installed a package.
See Code Examples for other Android PackageManager Methods: