Can a service show a popup window ?

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

Can a service show a popup window ?

Postby tikimove » Sun Mar 01, 2009 12:46 pm

Hello all,

I would like to do a service which periodically shows a popup window (or draw anything on the screen). Is it possible with Android ? I can't find this in the documentation.

Thank you very much
Sebastien
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Top

Postby abraxas » Sun Mar 01, 2009 10:21 pm

Just use a Toast!

Toast.makeText(this, "Your message", Toast.LENGT_SHORT).show();
abraxas
Junior Developer
Junior Developer
 
Posts: 20
Joined: Fri Feb 06, 2009 12:33 pm

Postby MrSnowflake » Mon Mar 02, 2009 9:46 am

Why do you need periodic dialogs? Services are meant to use the notification area, which is designed especially for notifications (as the name shows :D).

And yes, toasts would work, except the user can't see which application generated the toast.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby tikimove » Tue Mar 03, 2009 8:12 am

I think that Toast will not be enough. I need to compose a complex panel, with a lot of informations.

My goal is to make a service which downloads infos from internet, like an RSS reader, and which shows a popup when a new article is available. The popup should be in foreground, at least when no application is launched on the phone.

Thanks for your help
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Postby raggedtoad » Tue Mar 03, 2009 9:22 pm

Have you considered using a sub-activity with a different "Theme"? The theme option can be set in the manifest file. You could display all the information you wanted and then just have an "Okay" or "Close" button on your dialog that would return the user to the last page - Essentially, the same functionality of a popup.
User avatar
raggedtoad
Freshman
Freshman
 
Posts: 8
Joined: Fri Feb 06, 2009 6:04 pm

Postby tikimove » Wed Mar 04, 2009 9:01 am

Thanks for the tip, I will read some documentation.
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Top

Postby wilken » Fri Mar 06, 2009 11:23 am

tikimove wrote:Thanks for the tip, I will read some documentation.


I think the preferred way to do something like this is to use a notification to put an icon in the menubar, and then let the notification open an activity showing what has been downloading.

a toast would be irritating if it popped up when you were doing something else.

apart from that i am not sure a service CAN show a toast, since it does not have an UI thread (you might get exceptions talking about a Looper)
wilken
Developer
Developer
 
Posts: 35
Joined: Wed Oct 08, 2008 8:22 am

Postby ayesh » Fri Mar 06, 2009 1:33 pm

hi,
service can show pop up window

private void startservice()
{
final Handler handler=new Handler();

timer.scheduleAtFixedRate(new TimerTask(){
public void run()
{
try
{
int flag=checkBill();
if(flag==2)
{
flag=0;
handler.post(new Runnable(){
public void run()
{
check();

}
});
}

}
catch(Exception e){}
}
},0,INTERVAL);



}

this is my code here in start service method checking some condition and if true just creting another thread
i hope it will useful to u
sdfdg
ayesh
Freshman
Freshman
 
Posts: 6
Joined: Thu Feb 19, 2009 12:49 pm
Location: India

Postby ayesh » Fri Mar 06, 2009 1:35 pm

in check i am starting new intent which will show a pop up window
sdfdg
ayesh
Freshman
Freshman
 
Posts: 6
Joined: Thu Feb 19, 2009 12:49 pm
Location: India

Postby wilken » Fri Mar 06, 2009 1:40 pm

ayesh wrote:in check i am starting new intent which will show a pop up window


ah i see. my problem probably was that i didn't use a handler.
wilken
Developer
Developer
 
Posts: 35
Joined: Wed Oct 08, 2008 8:22 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests