What I need is very similar to the How to properly upgrade AIDL interfaces in Android? question, but I also want a newer version of the AIDL Service to launch after it is installed and the old one to stop. Simply put: I need that the newest version is always the running one. (Backwards-compatibilty of the newer version will, of course, be maintained.)
In detail, let's say our:
- Android app A has the older version of the AIDL Service in its code (and also stated as a special remote process in the manifest).
- App B is an app with the newer version of the AIDL Service, that the user has just installed.
When app B gets installed I programatically kill processes of both apps, and the remote process of the AIDL Service. Whatever I do to try to launch the AIDL Service contained in the newer app B after that point is of no use, the older version would always get relaunched (unless I uninstall the older app A).
The interesting thing is that I am able to specifically target the newer AIDL Service to start (bind to the Service from the newer app) if both apps are only installed, and the older version of the AIDL Service has never been started before. By this I mean that I launch the older app A and I am able to make it start the newer version of the AIDL Service inside the app B. If the older version of the AIDL has been run at least once in the past before, then it will be the one that the Android will always start in the future no matter what (even after rebooting the device)!