Updating UI from a service (using a handler?)

前端 未结 3 549
谎友^
谎友^ 2020-12-11 06:12

I am trying to update my UI in FirstActivity when I receive a notification but is confused by runOnUiThread , Runnable and Handl

3条回答
  •  一个人的身影
    2020-12-11 06:41

    My 1st instinct is that you should instead have the Activity bind to your service and handle the UI update on its side instead of the Service directly modifying the Activity.

    See more info here:
    http://developer.android.com/reference/android/app/Service.html#LocalServiceSample

    And an example here:
    Example: Communication between Activity and Service using Messaging

提交回复
热议问题