How to set time duration for an operation in android app?
<p>I am developing flashlight app. I want to set time like 2mins, 3mins and unlimited for the flashlight to be on. How can I do that?
First of all I am checking whether flashlight is available or not. If it is, I want to set the brightness to maximum.</p>

<p>My code contains the following.</p>

<pre><code>if (flashcheck) {
            camera = Camera.open();
            parameters = camera.getParameters();
            parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
            camera.setParameters(parameters);
        } else {
            WindowManager.LayoutParams localLayoutParams = getWindow()
                    .getAttributes();
            localLayoutParams.screenBrightness = 1F;
            getWindow().setAttributes(localLayoutParams);
        }
</code></pre>
