开发者

Displaying a toast from a Service

开发者 https://www.devze.com 2023-02-05 17:45 出处:网络
I have a service running 开发者_JS百科with a background thread polling for XMPP messages. I want to issue

I have a service running 开发者_JS百科with a background thread polling for XMPP messages. I want to issue a toast from the Thread. Previous stackoverflow questions have dealt with this by using the runOnUiThread Activity method, however this is not available in a Service. My question is what is the suggested method in a Service? Many thanks in advance


You could try to callbacks similar to the example at http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/RemoteService.html. Specifically see the section starting with the comment

/**
 * Our Handler used to execute operations on the main thread.  This is used
 * to schedule increments of our value.
 */
0

精彩评论

暂无评论...
验证码 换一张
取 消