asynchronous - how to start/stop a Timer/AsyncTask in an android view -
i need job executed @ fixed time(for example every 1 seconds).
i know can implement timer or asynctask.
however have start job when view created. wonder can stop job? since have not found lifecycle android.view.view.
what alternative solution?
i have custom view can used others, , have start timer or asynctask once view focused, , stop background job when view invisible.
since activity has view instance, call method of view let know view class activity destroyed or stopped, depending on requirement.
private view mview; public void ondestroy { super.ondestroy(); mview.stopcounter(); } public void onstop() { super.onstop(); mview.stopcounter(); }
Comments
Post a Comment