How to display an Alert from background thread ?

Put your problem here if it does not fit any of the other categories.

How to display an Alert from background thread ?

Postby fresco » Wed Nov 28, 2007 5:42 pm

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 ?
fresco
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Nov 18, 2007 10:36 am

Top

Postby plusminus » Wed Nov 28, 2007 5:58 pm

Hello fresco,

did you think about a Notification (in the Top-Bar) :?:
I would prefer that as a user, because it would not fill half of the screen.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby fresco » Wed Nov 28, 2007 6:03 pm

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 ..... ?".
fresco
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Nov 18, 2007 10:36 am

Postby plusminus » Fri Feb 15, 2008 11:34 am

Hello fresco,

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):
Image


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 10 guests