How to resume my activity from where user has long press(shut down) power button
<p>I am working on the application,I am having the requirement:if user long press the power button at any time and press again to start device,the activity should start from where the device was shut down.I dont know either this is a valid question or not.
I tried working with:  </p>

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

private static PowerManager objpowermanager;
private static PowerManager.WakeLock wl;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    callTOWakeLock();
    setContentView(R.layout.main);

}//end of onCreate
public void callTOWakeLock() {
    // TODO Auto-generated method stub
    objpowermanager=(PowerManager)getSystemService(Context.POWER_SERVICE);
    wl=objpowermanager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "******MyTag****");
    //You should acquire it when your app starts,
    if(wl.isHeld())
    {
        wl.release();
    }
    wl.acquire(); 

}
@Override
public void onDestroy() {
    wl.release();
}
@Override    
protected void onStop() {
    // TODO Auto-generated method stub
    super.onStop();

}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    callTOWakeLock();
}
/*@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_POWER) {
        Intent i = new Intent(this, PowerMangerTestActivity.class);
        startActivity(i);
        return true;
        TextView tv=(TextView) findViewById(R.id.textview);
        tv.setText("You press power button");
    }

    return super.dispatchKeyEvent(event);
}*/
</code></pre>

<p>}
but not getting expected behaviour.<br>
I have tried to catch <code>KeyEvent.KEYCODE_POWER</code>,but not getting how to use for this scenario.
any suggestions?
thanks</p>
