Android : error when using a runnable in an async task
<p>I want to update a variable in my activity once every one second and for that i am using an Async task and a runnable inside it. I keep getting this error saying "Cannot refer to a non-final variable myRunnable inside an inner class defined in a different method" . When i change the declaration to final , it shows "The local variable myRunnable may not have been initialized" . How do i rectify the error? Is there a better way of doing what i want to do?</p>

<pre><code>    import android.os.AsyncTask;
    import android.os.Handler;

    public class Timer extends AsyncTask&lt;String, Process, Void&gt;{
static int seconds=0;
TimerTask timer;
static int minutes=0;
static int hours=0;
private String timeTaken;
public Handler myhandler = new Handler();

@Override
protected Void doInBackground(String... params) {

   final Runnable myRunnable = new Runnable() {

@Override
public void run() {
    ......
......
    ...... 
myhandler.postDelayed(myRunnable, 1000);
}
};

    return null;
}   
</code></pre>
