Screen on/off detection
<p>here i am trying to determine whether the screen is on or not but it doesn't seems to be working when press power lock/unlock button. Application works with no error but the code in if-else doesnt seems to have effect. 
<strong>Edited</strong>
now the code work(thanks <strong>Olgun</strong>) but the mediaplayer playback doesnt stops and every time on/off screen new mediaplayer objct is created(multiple playbacks ). </p>

<p><strong>SCBroadcaster.java</strong> </p>

<pre><code>    public class SCBroadcaster extends BroadcastReceiver {
    PowerManager pm;
    MediaPlayer mp;
    public static boolean wasScreenOn = true;

    @Override
    public void onReceive(Context arg0, Intent arg1) {
        // TODO Auto-generated method stub
        mp = MediaPlayer.create(arg0, R.raw.gale);
        if (arg1.getAction().equals(Intent.ACTION_SCREEN_ON)) {
                    mp.stop();
            mp.release();
            Toast.makeText(arg0, "oNONONO", Toast.LENGTH_LONG).show();

        } else if (arg1.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
            mp.start();
        }

    }

}
</code></pre>

<p><strong>MainActivity.java</strong></p>

<pre><code>public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_SCREEN_ON);
    BroadcastReceiver bre = new SCBroadcaster();
    registerReceiver(bre, filter);
}

protected void onPause() {
    super.onPause();
    if (SCBroadcaster.wasScreenOn) {
        System.out.println("SCREEN TURNED OFF");
    } else {

    }
}

protected void onResume() {
    super.onResume();
    if (!SCBroadcaster.wasScreenOn) {

    } else {

    }
}
</code></pre>

<p>}</p>
