Friday, June 11, 2010

Re: [android-developers] how to display a Toast from an IntentService?

Flying Coder wrote:
> So, I have an IntentService that handles button callbacks from a
> widget. When the user presses a certain button, I want to display a
> Toast. I return from onHandleIntent almost immediately after doing
> Toast.show(), which in turn stops the service and kills its thread,
> which keeps the Toast from actually being displayed.

That's interesting. I've never tried that pattern. I'm a bit surprised
that the Toast doesn't fire.

> Can anyone suggest an easy way to get the Toast (or something similar)
> to display from an IntentService?

Have you tried SystemClock.sleep()? It's a serious kludge, but I don't
know what else you can do.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment