package com.example.zuankemode.Utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by Suchbear on 2018/1/8.
 */

public class VersionUtils {
    private static PackageManager manager;

    private static PackageInfo info = null;

    private Context context;
    private static VersionUtils utils ;

    public VersionUtils(Context context)
    {
        this.context = context;
    }

    public static VersionUtils getInstance(Context context)
    {
        if (utils==null)
        {
            utils = new VersionUtils(context);
        }

        manager = context.getPackageManager();

        try {

            info = manager.getPackageInfo(context.getPackageName(), 0);

        } catch (PackageManager.NameNotFoundException e) {

            e.printStackTrace();
        }

        return utils;
    }

    public String getVersionName()
    {

        return info.versionName;
    }

    public int getVersionCode()
    {
        return info.versionCode;
    }

    public String getPackageName()
    {
        return info.packageName;
    }

    public android.content.pm.Signature[] getSignatures()
    {
        return info.signatures;
    }
}
