2

I want to add a "about" item to my android application, and I want to display the apk's compile and build time in this item. How can I achieve this? Any suggestion? Thanks.:-)

FallingRain
  • 671
  • 1
  • 5
  • 7
  • http://stackoverflow.com/questions/7607165/how-to-write-build-time-stamp-into-apk for those who land here instead of the same question with an accepted answer – soulseekah Feb 26 '12 at 23:15

1 Answers1

0

I'd say include it into your android:versionName attribute. You probably have to modify that with a build-script though.

The version number shown to users. This attribute can be set as a raw string or as a reference to a string resource. The string has no other purpose than to be displayed to users. The versionCode attribute holds the significant version number used internally.

You can read that at runtime via

ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName

ctx is a Context instance, you can use this in every activity or service instead

  • It's helpful, thanks very much. But I wish I could get the build time stamp dynamicly. I mean, the build time stamp should change since I build the application again dynamicly, not be written manually. – FallingRain Sep 21 '11 at 04:28
  • Yes, was mostly a sidenote for the place, not how to get the timestamp. Not sure if APKs have a build-timestamp at all, that's why i mentioned using a build-script that writes the value at buildtime. Let's wait and see, maybe someone knows some more. –  Sep 21 '11 at 10:29
  • hi, alextsc. I'm trying to use a build-script that writes the time stamp at build time.As we know, we can add Android.mk in the root folder of our application, and when we build this application using make, the Android.mk will be called. So, I can get time stamp using date marco. But, how can I write this value into my apk? cause I need to read and display the build timestamp in my About Activity. activity. – FallingRain Sep 30 '11 at 07:06
  • Hey, I'm sorry im not too familiar with make. I know what it is, but is has been a while since i wrote a buildscript myself. So I'd suggest to open a dedicated question for this. :) –  Sep 30 '11 at 09:14