Updating a seekbar using a handler
<p>In my application I must update a seek bar. As I understand, if I'm using the handler I don't need to use another thread. The problem is that the handleMessage method gets called only once. Here is my sample code.</p>

<pre><code>private Handler mHandler = new Handler() {
    @Override
    public void handleMessage(Message msg) {
        int pos;
        pos = setProgress();

        if (mVideoView.isPlaying()) {
            System.out.println("__handleMessage__isPlaying");
            Message msg1 = obtainMessage(REPORT_MSG);
            sendMessageDelayed(msg1, 1000 - (pos % 1000));
        }
    }
};

private int setProgress() {
    SeekBar mProgress = (SeekBar) findViewById(R.id.progress);
    if (mVideoView == null) {
        return 0;
    }

    int position = mVideoView.getCurrentPosition();
    int duration = mVideoView.getDuration();

    if (mProgress != null) {
        if (duration &gt; 0) {
            // use long to avoid overflow
            long pos = 1000L * position / duration;
            mProgress.setProgress( (int) pos);
        }
        int percent = mVideoView.getBufferPercentage();
        mProgress.setSecondaryProgress(percent * 10);
    }

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

<p>Thanks a lot,</p>

<p>Gratzi</p>
