如何写建立时间标记成APK [英] How to write build time stamp into apk

查看:124
本文介绍了如何写建立时间标记成APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 在制作一些Android的通讯录包变更
  2. 使用毫米(使)命令来构建这个应用程序
  1. Making some changes in Android Contacts package
  2. Using mm (make) command to build this application

由于我必须要改变,再而建立这个程序,所以我想补充一个构建时间戳的 Contacts.apk 来,当我们检查的编译时间银行经营它在听筒。

Because I have to change and build this app again and again, so I want to add a build time stamp in the Contacts.apk to check the build time when we runn it in the handset.

我们知道,当我们运行毫米命令时, Android.mk (生成文件)中的联系人包将叫做。

As we know, when we run mm command, the Android.mk (makefile) in Contacts package will be called.

而现在,我们可以用得到的编译时间日期 -macro。

And now, we can get the build time using date-macro.

但是,我们如何才能写此版本时间戳到我们的应用程序都可以在运行时读取一个文件?

But how we can write this build time stamp into a file that our application can read at runtime?

有什么建议?

推荐答案

方法,检查classes.dex的最后修改日期,这意味着当你的应用程序的code建末班时间:

Method which checks date of last modification of classes.dex, this means last time when your app's code was built:

  try{
     ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), 0);
     ZipFile zf = new ZipFile(ai.sourceDir);
     ZipEntry ze = zf.getEntry("classes.dex");
     long time = ze.getTime();
     String s = SimpleDateFormat.getInstance().format(new java.util.Date(time));
     zf.close();
  }catch(Exception e){
  }

测试,工作正常,即使应用程序安装在SD卡。

Tested, and works fine, even if app is installed on SD card.

这篇关于如何写建立时间标记成APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆