I am working on an Android app that has only one Trusted Web Activity
(TWA).
For example, in a new version of my app, I change the base URL for the TWA from https://example.com
to https://example.com/something
.
The issue arises when a user has the old version of the app open, then goes somewhere else, downloads, and installs the updated APK without closing the app. In this scenario, the old activity remains open and doesn’t restart with the updated URL. As a result, the user has to manually close and reopen the app to load the new version with the correct URL.
I’ve tried checking the lifecycle callbacks such as onCreate
, onStart
, onResume
, and onPause
, but none of them are triggered after the app is updated while the activity is still running.
Is there a way to programmatically detect that the app has been updated and restart the TWA activity? Or is there another solution to ensure the TWA loads the updated URL after an app update?