Android Service Multiple Thread Design

前端 未结 1 1233
北恋
北恋 2020-12-17 00:41

A new question about android and services. Currently I\'m developing a App that should send images to a server. It should also be possible to send more images parallel.

相关标签:
1条回答
  • 2020-12-17 00:59

    I would use a Controller object that is created in your application class. This controller is the same for all your activities. If an image upload is started the controller creates a new service/thread and monitors it state and shows the notification. Every activity now can ask the controller for the state of its process and show the corresponded information to the user. This way the controller living in the application lifecyle will bind to the service and not the short lived activity

    There was a talk from mark brady on droidcon about this you can find the slides on slideshare. It gets interesting in the later part of the slides when the architecture mark used is explained. I fought with the same problem for some weeks and came to the same results and I'm glad that finally some kind of resource exists on the net on this topic.

    0 讨论(0)
提交回复
热议问题