Note that there are some explanatory texts on larger screens.

plurals
  1. POBest Android threading technique for long-running tasks?
    primarykey
    data
    text
    <p>The thing is, that I have to keep a thread running for a pretty long time (it's really an indefinite time, could be 1 minute or even months), and it needs to update the UI about once every 1 milisecond...</p> <p>There is the <code>Executor</code>, <code>AsyncTask</code>, <code>Handler</code> and the native <code>Thread</code> class... but which one is better for this case?</p> <p>The problem with <code>AsyncTask</code> is that it is destroyed (or detached from the <code>Activity</code>?) like one hour or so after the <code>Activity</code> starts running on background, and the user could return to the <code>Activity</code> at any time just to find that it's not working (and even causing memory leaks), and the UI lags when changing to another activity or even pulling down the notification panel.</p> <p>Natural Threads are even more laggy due to the <code>post()</code> method being called on the <code>TextView</code> every time I need an update to the UI (remember that I need to report progress about once every 1 milisecond)...</p> <p><strong>tl:dr</strong> I'm developing a long running stopwatch, that can measure from miliseconds to days, weeks or even <strong>years</strong>. What is the best <strong>UI-intensive</strong> threading technique for this?</p> <p>Could you please help me? Thanks!!</p> <p>--- Edit: Solved. It had to do something with system resources and the app moving to background. I just had to save the inital time and pauses as a bundle and load them when the app is started again. Thank you everyone!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload