Try using Handler: instead of showing toast from non-GUI thread, use handler.post() method to schedule toast for execution in UI thread.
On Sep 30, 8:42 pm, Omer Gilad <omer.gi...@gmail.com> wrote: > Hello, > I have an application which runs a background thread which eventually > updates listeners on some incoming event. > When I'm in this listeners' code, I want to be able to either show a > Toast or a new Activity on top of the screen, regardless of what is > running in this moment - but to be able to come back to it (add on top > of the current stack, even if it's another application). > By now I didn't succeed in doing that in any way. > > This is one attempt (inside my listener, which is called from a worker > thread): > > runOnUiThread(new Runnable() { > > public void run() { > Toast.makeText(getApplicationContext(), > "toast", Toast.LENGTH_LONG).show(); > > } > }); > > It shows the toast when I am in my original application, but not when > I'm in background. > I put a breakpoint on the line with the toast showing, and I know that > I get there, but it does nothing. > > Do you have any idea? > > Thanks ahead! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---