How to pop up a system message?

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

How to pop up a system message?

Postby paulscode » Mon Sep 12, 2011 5:39 pm

You know those little system messages that pop up for a short while then disappear? I'd like to use those to notify the users of one of my apps when certain events in the program occur (mainly because they are small and non-intrusive). Could anyone direct me on how to do this? (preferably a small complete example, rather than links to the API which are not easy to follow IMHO) Thanks in advance!
paulscode
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Thu Nov 11, 2010 3:57 pm

Top

Re: How to pop up a system message?

Postby jonbonazza » Mon Sep 12, 2011 5:42 pm

You mean a Toast?

They can be done in one line of code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Toast.makeText("MyTag", "This is the text that will display").show();
  2.  
Parsed in 0.029 seconds, using GeSHi 1.0.8.4


Note, however, that a Toast must be performed from the UI thread, thus in order to make a Toast from another thread, you need to use a Handler.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: How to pop up a system message?

Postby paulscode » Mon Sep 12, 2011 8:21 pm

Thank you much. I'll give it a shot. Probably will have to use the handler, since it will be coming potentially from a couple different threads. I'll look into that.
paulscode
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Thu Nov 11, 2010 3:57 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 18 guests