문제

Let's say I wan't to do work in the background (off the main thread).

If only one activity needs the result of this background work, is there any difference between starting this off-main-thread work from a service or from an activity? If so, what is the difference?

[Edit 1 start]

Is it something related to component life cycles. An activity might be stopped (and the off-main-thread continues) but then the process might get killed without onDestroy being called. Is onDestroy guaranteed to be called from a service?

[Edit 1 end]

도움이 되었습니까?

해결책

None. The different is basically on the lifecycle of the holding object (i.e. Activity or Service), for instance, if you start a Thread on the Activity.onResume() and you move away from that activity (e.g. press home button) before that thread finishes the execution, it will be likely to be holding an instance of a 'dead' activity that could potentially leads to other problems.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top