In my application I have a background thread for uploading/downloading files. While file is being downloaded user can switch between couple of application activities. When download ends I want to inforn the user about that but I don't know how I can get active activity to call showAlert() method. Is there any way to get current activity reference from background thread ?
No, I can't. By system requirements I have to ask user if he wants to open the file, so I must show a dialog window with question "Do you want to open ..... ?".
you could use a Handler to do so (some how make the MainActivity accessible from the background Thread, easy to do if you create the within that MainActivity, because then you can use the this-Pointer of the MainActivity):