new Date(System.currentTimeMillis()).getTime() 我用这个不行啊!
1 回答
哔哔one
TA贡献1854条经验 获得超8个赞
public static long getApkUpdateTime(Context context) {
PackageManager pm = context.getPackageManager();
ZipFile zf = null;
try {
PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
zf = new ZipFile(packageInfo.applicationInfo.sourceDir);
ZipEntry ze = zf.getEntry("classes.dex");
return ze.getTime();
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (zf != null) {
try {
zf.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return 0;
}
- 1 回答
- 0 关注
- 259 浏览
添加回答
举报
0/150
提交
取消