android: what's the difference between a timertask and a service?
<p>I'm using a timertask in the main activity in order to update some data repeatedly every X seconds.</p>

<p>This data is of static form, so it's a public static method</p>

<p>is this a bad technique? I mean, using static methods like this</p>

<p>I know there's this thing called Service, but there aren't really many examples online on how to use it in order to update every X seconds a variable that should be then accessed by some activity</p>

<p>so my question is, what's the difference between using a timer task and a service? is a timertask just a time counter and nothing else? does it run in parallel if it's being used with a handler or not? and what happens if you have something like this:</p>

<pre><code>       handler = new Handler();
    t = new Timer();
    task = new TimerTask() {
        public void run() {

            handler.post(new Runnable() {
                public void run() {

                                         //do stuff;

                }
            });

        }

    };
    t.schedule(task, 0, 10000);
</code></pre>

<p>how exactly does this code work? what does it do? does it run in parallel? why even if I leave the activity where this code is first being called, it still runs? what makes it run in this case? </p>

<p>thanks in advance</p>
