Here's a very simple solution:
You could have your Paid App periodically look for the existence of a "kill" file (i.e. KILLREQFILE) on a timer(to conserve battery life). This file does not have to have anything in it. If the file exists it would delete it and perform a graceful exit. The Free App would create the KILLREQFILE whenever it is time to kill off the paid peer app. The Free App would not create the file it if it already existed. I could even check to see if it's KILLREQFILE was deleted after created and log the fact that the Paid App was successfully killed off since no other process in the system would ever delete the kill file under in normal circumstances. To insure integrity, The Free App would have to detect the existence of the KILLREQFILE at least once to insure that it was indeed created before assuming that the Paid App was truly killed off. Before EXITING, the Paid App could write another file KILLACK FILE to notify the Free App that it detected the KILLREQFILE and did it's exit. The idea here is synchronization so that files aren't left around when they shouldn't be in case of a process failure or intervention by the User. Make sure that the Free App deletes the KILLACKFILE and KILLREQFILE if they exist when the app is started.
I've done this sort of thing in other programming languages as sort of a poor man's semaphore and messaging system.
Try it out. It should work well and does not involve any system libraries or PID's, etc. You could test it manually by creating the kill file yourself and see if your App deletes the file and exits.
By using two different files each version of your app can insure that it is the only one running. Just reverse the logic described above.
I think I'll implement this in my next project myself... Simple yet elegant.
Regards,
Ray
Last edited: Jun 23, 2012
------------------------------------------------------
HTC Droid Incredible, T-Mobile Samsung Galaxy S 4G, Samsung Galaxy Tab 7" running Gingerbread , Samsung Galaxy S Blaze running Ice Cream Sandwich 4.0.4, Dell Inspiron running Windows 7 Home Premium.
[SIGPIC][/SIGPIC]