package com.tenlionsoft.baselib.core.network.update;

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

/**
 * Created by Xuer on 2017/3/9.
 */
public class CheckUpdateUtils {

    /**
     * 根据版本号大小判断是否需要更新
     *
     * @param context
     * @param versionCode 服务端传回来的版本号
     * @return
     */
    public static boolean checkcode(Context context, String versionCode) {
        PackageInfo packageInfo = null;
        try {
            packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        boolean isupdate = packageInfo.versionCode < Integer.parseInt(versionCode);
        return isupdate;
    }
}
