Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import java.util.List;

public class Main {

    public static String getAppSign(Context context, String packageName) {
        PackageManager pm = context.getPackageManager();
        List<PackageInfo> packages = pm.getInstalledPackages(PackageManager.GET_SIGNATURES);
        for (PackageInfo pkg : packages) {
            if (packageName.equals(pkg.packageName)) {
                return pkg.signatures[0].toCharsString();
            }
        }

        return null;
    }
}