I want my program to do what android does when on call and close to face.
<p>I know that this is similiat to this question
<a href="http://stackoverflow.com/questions/3018716/android-turn-off-screen-when-close-to-face">android: turn off screen when close to face</a>
and many others. But I could't find any working solution. </p>

<p>So I have a program that plays audio. I listen to proximity sensor:</p>

<pre><code>@Override
public void onSensorChanged(SensorEvent event) {
    if(event.values[0] == 0.0){
        //phone close to face
        playAudio();
    }else{
        //phone away
        stopAudio();
    }
</code></pre>

<p>I have used this code to disable creen when close to face:</p>

<pre><code>WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = 0;
getWindow().setAttributes(params); 
</code></pre>

<p>But I don't know how to get it back :)
I tried:</p>

<pre><code>WindowManager.LayoutParams params = getWindow().getAttributes();
params.screenBrightness = 1f; //tried all (1, 100, -1, 0)
getWindow().setAttributes(params); 
</code></pre>

<p>And some suggested: </p>

<pre><code>PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
wakeLock.acquire();
</code></pre>

<p>But nothing works. The audio is stopped when I move phone away from face. So activity is not paused.</p>
