android 获取程序的安装时间
虽然google有在PackageInfo里提供firstInstallTime这个接口(其实是一个public字段),但似乎无用,返回值为零。google了下 真正可以获取安装时间要变通下
- PackageManager pm = context.getPackageManager();
- ApplicationInfo appInfo = pm.getApplicationInfo("app.package.name", 0);
- String appFile = appInfo.sourceDir;
- long installed = new File(appFile).lastModified();