I have an application that downloads encrypted pdf files from server. Then when user chooses to read pdf, file will be decrypted and opened with whatever suitable application on user's device is found.
How do I know when user goes back from application or switches to another application or presses home button, so I can delete decrypted file stored on device?