Make flashlight app work when the application is closed
<p>I have this code that allows me to press a button to turn on my phones flashlight. What would be the best way to keep the light on, while the application is closed? I heard asynctask is good, but I read that it's meant for a background task that will communicate with the UI. What kind of "thread" should I use for this type of "application".</p>

<p>My onClickListener code:</p>

<pre><code>button.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
        //If Flag is set to true
        if (isFlashOn) {
        Log.i("info", "torch is turned off!");
        //Set the flashmode to off                    
        p.setFlashMode(Parameters.FLASH_MODE_OFF);
        //Pass the parameter ti camera object
        camera.setParameters(p);    
        //Set flag to false                
        isFlashOn = false;
        //Set the button text to Torcn-ON
        button.setText("Torch-ON");
        } 
        //If Flag is set to false
        else {
        Log.i("info", "torch is turned on!");
        //Set the flashmode to on
        p.setFlashMode(Parameters.FLASH_MODE_TORCH);
        //Pass the parameter ti camera object
        camera.setParameters(p);
        //Set flag to true
        isFlashOn = true;
        //Set the button text to Torcn-OFF
        button.setText("Torch-OFF");
        }
            }});


    }
</code></pre>
