package com.joy.library.utils;

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

import com.joy.library.BaseApplication;

/**
 * Created by KEVIN.DAI on 15/7/10.
 */
public class AppUtil {

    /**
     * 获取应用第一次安装时间
     *
     * @return
     */
    public static long getInstallAppTime() {

        long firstInstallTime = 0;

        try {

            Context ctx = BaseApplication.getContext();
            PackageInfo packageInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
            firstInstallTime = packageInfo.firstInstallTime;// 应用第一次安装的时间

        } catch (Exception e) {

            e.printStackTrace();
        }

        return firstInstallTime;
    }
}

@@ -95,16 +95,58 @@
 ageInfo;
+%0Aimport android.content.pm.PackageManager;
 %0A%0Aimport
@@ -752,10 +752,926 @@
 ;%0A    %7D%0A
+    /**%0A     * %E8%8E%B7%E5%8F%96VersionCode%EF%BC%8C%E9%BB%98%E8%AE%A4%E8%BF%94%E5%9B%9E1%0A     * @return%0A     */%0A    public static int getVersionCode() %7B%0A%0A        try %7B%0A%0A            Context ctx = BaseApplication.getContext();%0A            PackageInfo packInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);%0A            return packInfo.versionCode;%0A%0A        %7D catch (PackageManager.NameNotFoundException e) %7B%0A%0A//            if(LogMgr.isDebug())%0A                e.printStackTrace();%0A        %7D%0A%0A        return 1;%0A    %7D%0A%0A    public static String getVersionName() %7B%0A%0A        try %7B%0A%0A            Context ctx = BaseApplication.getContext();%0A            PackageInfo packInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);%0A            return packInfo.versionName == null ? %22%22 : packInfo.versionName;%0A%0A        %7D catch (Exception e) %7B%0A%0A//            if(LogMgr.isDebug())%0A                e.printStackTrace();%0A        %7D%0A%0A        return %22%22;%0A    %7D%0A
 %7D%0A

添加工具,日志