Show ProgressDialog in a Service class

*爱你&永不变心* 提交于 2019-12-01 08:51:08

So a service is NOT the UI you have to use the observer pattern. Your activity have to register a listener in the service so that the service can inform the activity for special events (like start loading or finish loading).

You have to add following intercae into your service class:

    public interface serviceObserver {
        public void startLoading();
        public void stopLoading();
    }

Your activity has to implement serviceObserver. Your service has to store a instance from serviceObserver which is created in the activity. If your service is running without your activity i recommend to use broadcast receiver for communication.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!