Lock screen on shake
<p>I want to lock the screen on shaking of the phone i have created shaking listener and it detecting the shaking of the phone
The code is..</p>

<pre><code> Receiver myReceiver;
 Context context1;

  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Vibrator vibe = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);

    mShaker = new ShakeListener(this);
    mShaker.setOnShakeListener(new ShakeListener.OnShakeListener () {
      public void onShake()
      {

        vibe.vibrate(100);
        new AlertDialog.Builder(MainActivity.this)
          .setPositiveButton(android.R.string.ok, null)
          .setMessage("Shooken!")
          .show();

       PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE);

        // Choice 1
 //         manager.goToSleep(amountOfTime);

// Choice 2
    PowerManager.WakeLock wl = manager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "Your Tag");
        wl.acquire();
        wl.release();



                }

    });
  }

  @Override
  public void onResume()
  {
    mShaker.resume();
    super.onResume();
  }
  @Override
  public void onPause()
  {
    mShaker.pause();
    super.onPause();
  }
}
</code></pre>

<p>The alert dialog is there but its not locking the phone how can i do it</p>
