Example: Communication between Activity and Service using Messaging

前端 未结 9 651
既然无缘
既然无缘 2020-11-22 00:06

I couldn\'t find any examples of how to send messages between an activity and a service, and I have spent far too many hours figuring this out. Here is an example project fo

9条回答
  •  孤独总比滥情好
    2020-11-22 01:04

    Message msg = Message.obtain(null, 2, 0, 0);
                        Bundle bundle = new Bundle();
                        bundle.putString("url", url);
                        bundle.putString("names", names);
                        bundle.putString("captions",captions); 
                        msg.setData(bundle);
    

    So you send it to the service. Afterward receive.

提交回复
热议问题