repeat task in Android
<p>I try to toggle the screen brightness low and high periodically (1s) and I thought this code should work:</p>

<pre><code>SystemClock.sleep(1000);
params.screenBrightness = 0;
getWindow().setAttributes(params);


SystemClock.sleep(1000);
params.screenBrightness = 1;
getWindow().setAttributes(params);
</code></pre>

<p>I have tried these codes but it only completes the second one (or last one if i extend the codes) (i.e. brightness=1). As I doubt about that so I put a variable int i = 0, then i++ after each sleep function, it shows me i = 2 after all (by displaying string). I think Android does the sum but my screen just react to the last setting but not the intermediate commands. Do you have any idea why it is that and how can I toggle the screen brightness?</p>

<p>I also try to use "for" loop but no luck.</p>

<p>Hope to receive your comments asap.</p>

<p>Cheers,</p>
