Android design pattern for background operation with UI and non-UI modes

前端 未结 2 1670
猫巷女王i
猫巷女王i 2021-01-26 06:46

I have a background operation that I\'d like to be able to run in two modes:

  • UI mode, which is launched by the user and provides the user preci

2条回答
  •  有刺的猬
    2021-01-26 07:25

    Instead of having an object doing the same stuff through different ways (UI / non-UI), I would move the business logic into a separate class, then have two different objects (AsyncTask and IntentService) being activated at the time you need, and use that object within. Also, what kind of task are you planning on running in your AsyncTask?

提交回复
热议问题