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

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -