Android Question [SOLVED] Reading .apk file

JoeR

Member
Licensed User
Longtime User
Can a B4A app read the timestamp type info in the apk file? (on a non-rooted Android device)

I want to do this to implement a method of version checking/confirmation which is more automated than the VersionCode/Name in the Manifest.

The apk file contains what I need.

I know that it can be done because I have a free app APK extractor which appears to be able to read all apk files on my device. See attached screenshot. I am interested in the Last Modified date at the bottom of the screenshot.
 

Attachments

  • SC20140205-234147.png
    SC20140205-234147.png
    163.7 KB · Views: 255

NJDude

Expert
Licensed User
Longtime User
Try this (you need the Reflection lib):
B4X:
Sub GetUpdateDate(Package As String) As Double

	Dim r As Reflector

    r.Target = r.GetContext  
    r.Target = r.RunMethod("getPackageManager")
    r.Target = r.RunMethod3("getPackageInfo", Package, "java.lang.String", 0x00000001, "java.lang.int")

    Return r.GetField("lastUpdateTime")

End Sub
 
  • Like
Reactions: eps
Upvote 0

JoeR

Member
Licensed User
Longtime User
Perfect solution. With thanks to NJDude.

I used the Date.Time object to manipulate the output produced by NJDude's GetUpdateDate Subroutine
 
Upvote 0
Top