How to reduce the time delay between Activity Pause and Re-Start(by a Service)?
<p>I am implementing an activity to be on top always ( generally implementing a lock screen),
The Algorithm is simple as :</p>

<ol>
<li>Start Activity</li>
<li>Disable All Hardware buttons, disable backpress,camera lock, volume buttons etc. </li>
<li>Whenever activity is paused call a service to check and restart the activity.</li>
</ol>

<p>Refer to these answers for the logic: <a href="http://stackoverflow.com/questions/13658567/how-to-disable-all-hardware-keys-programatically-in-android.">Answer 1</a>, <a href="http://stackoverflow.com/questions/3262157/how-to-check-if-my-activity-is-the-current-activity-running-in-the-screen">Answer 2</a>
There is a 6-7 seconds delay whenever the Activity is paused, and is restarted by the Service. How may I reduce this time delay between the pause and restart of my Activity.</p>

<p>On Pause and On Resume Code:</p>

<pre><code>protected void onPause() {
    isFront = false;
    Intent lockHelper = new Intent( this, LockHelper.class);
    startService( lockHelper );
    super.onPause();
}


@Override
public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
    if(keyCode==KeyEvent.KEYCODE_CAMERA)
        return true;
    else if(keyCode==KeyEvent.KEYCODE_VOLUME_DOWN)
        return true;
    else if(keyCode==KeyEvent.KEYCODE_VOLUME_UP)
        return true;
    else if(keyCode==KeyEvent.KEYCODE_HOME)
        return true;
    else if(keyCode==KeyEvent.KEYCODE_POWER)
        return true;
    else 
        return true;
}

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent keyEvent) {
    if(keyCode==KeyEvent.KEYCODE_HOME)
        return true;
    else if(keyCode==KeyEvent.KEYCODE_POWER)
        return true;
    else 
        return true;
}

@Override
public void onBackPressed() {
}

@Override
protected void onResume() {
    isFront = true;
    Intent lockHelper = new Intent( this, LockHelper.class);
    startService( lockHelper );
    super.onResume();
}
</code></pre>

<p>}</p>

<p>Service is:</p>

<pre><code>public class LockHelper extends Service {
@Override
public void onStart(Intent intent, int startId) {
    if(Locker.isFront == false){
        Intent locker = new Intent( this, Locker.class);
        locker.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity( locker );
        stopSelf();
    }
}

public LockHelper() {
}

@Override
public IBinder onBind(Intent intent) {
    throw new UnsupportedOperationException("Not yet implemented");
}
}
</code></pre>
