How to observe state of third party application st

2019-05-31 15:57发布

问题:

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?