Skip to content Skip to sidebar Skip to footer

Toast In A Self Running Service

I have an android activity which runs a remote service and then quits. The service itself, polls on a device node, and checks for changes, I want to use toast to alert the user, bu

Solution 1:

You can't call a Toast message from the Service. You can't do anything with the UI except from the UI thread. You're going to need to research one of the many ways to communicate with your UI thread from your service - BroadcastReciever, Messenger, AIDL, etc.

For what you're trying to do, you probably don't need to go as far as the AIDL route. Check out this example the Messenger implementation and then check out the complete example from the sdk-samples:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/MessengerService.html

Post a Comment for "Toast In A Self Running Service"