Old date returned by getPackageInfo() on Wear OS 3?

Viewed 24

I have been using the following code to show when I created the package (Android Studio)

val pInfo: PackageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), 0)
val versionDate = pInfo.lastUpdateTime
val versionDateAsString = SimpleDateFormat("dd/MM/yy HH:mm:ss").format(versionDate)
Toast.makeText(this, "Package Created $versionDateAsString", Toast.LENGTH_LONG).show()

The above code snippet works perfectly for packages loaded onto my Ticwatch 3 (running Wear OS 2)

Unfortunately it does not work when the same package is loaded onto my Samsung Watch4 (Wear OS 3). Instead it shows the first time the package was loaded?

UPDATE 1:

It appears this is expected behaviour - The old date is returned when the code is run on an emulated Wear device.

Notes

  1. Even cleaning and rebuilding the entire package still results in the emulator showing the time and date the package was first run on the emulator.

  2. The emulator is set to API 30 and I admit I have not tested on an emulator running API 28 (I want the date to show on the Galaxy Watch4)

Frustrating!

0 Answers
Related