I have an Android Activity and user starts some task (for example by a button click) which may take some time - say something between between 1 ms and 1 min. It can be some network operation or computing or anything other. I can use a Thread or AsyncTask or some other tool. I want to change something on the Activity when the task finishes, for example show the downloaded image or best chess move etc. I must use Handler or some equivalent tool to run the main thread but it is still clear and quite simple. And here is my problem:
What is the recommended way to get the current Activity object (to call some its method)? Please note that user may not do anything during the task life (I want to get the original Activity object), he may also close the Activity by back key (I want to get null in this case - even if he reopens the Activity for the second time), he may change the configuration - for example switch from portrait to landscape mode (I want to get the new - current instance of the Activity).