application loses touch input after restarting
<p>I'm writing a 2D engine on android. I can receive touch input and update my scene according to touch events but there is a problem. When I restart the application after losing focus (clicking home screen button, receiving a call etc..) I can no longer receive touch input, screen still displays the content but it stays frozen. 
Is there a way to fix this issue?</p>

<p>Here is the code : </p>

<pre><code>import android.os.Bundle;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.app.Activity;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.WindowManager;
import android.media.AudioManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.util.DisplayMetrics;

public class SolarFighter extends Activity implements OnTouchListener
{
Game            game;
GraphicsManager graphicsMan;
SoundManager    soundMan;
ErrorManager    errorMan;
FrameSetManager frameSetMan;
SpriteManager   spriteMan;
InputManager    inputMan;
WakeLock        wakeLock;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    //
    //Go full screen
    //

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);
    wakeLock                  = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock");


    //
    // Get system information
    //

    DisplayMetrics displaymetrics = new DisplayMetrics();

    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

    int height = displaymetrics.heightPixels;
    int width  = displaymetrics.widthPixels;

    //
    // Create Graphics Manager and load spriteSheets load fonts
    //

    graphicsMan = new GraphicsManager(width,height,this);
    graphicsMan.addFont(0, "fonts/font.ttf", this);      

    //
    // Create Sound Manager and add sounds
    //

    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    //
    // Create Input Manager
    //
    inputMan = new InputManager();

    //
    // Create Frame Set Manager and add frame sets
    //

    //
    // Create Sprite Manager and add sprites
    //

    //
    // Create Entity Manager and add entities
    //

    //
    // Create Game
    //

    game = new Game(this);

    game.setOnTouchListener(this);  
    setContentView(game);

}

public void onResume() 
{
    super.onResume();

    wakeLock.acquire();

    game.resume();
}

public void onPause()
{
    super.onPause();

    wakeLock.release();

    game.pause();
}

public boolean onTouch(View v, MotionEvent event) 
{
    switch (event.getAction())
    {
        case MotionEvent.ACTION_DOWN:
            inputMan.setTouchState(InputManager.TOUCH_DOWN);
            inputMan.setLastX((int)(event.getX()));
            inputMan.setLastY((int)(event.getY()));
        break;

        case MotionEvent.ACTION_MOVE:
            inputMan.setTouchState(InputManager.TOUCH_MOVE);    
            inputMan.setCurrentX((int)(event.getX()));
            inputMan.setCurrentY((int)(event.getY()));
            inputMan.setRelativeX(inputMan.getCurrentX() - inputMan.getLastX());
            inputMan.setRelativeY(inputMan.getCurrentY() - inputMan.getLastY());    
            inputMan.setLastX(inputMan.getCurrentX());
            inputMan.setLastY(inputMan.getCurrentY());
        break;

        case MotionEvent.ACTION_CANCEL:
            inputMan.setTouchState(InputManager.TOUCH_UP);
        break;

        case MotionEvent.ACTION_UP:
            inputMan.setTouchState(InputManager.TOUCH_UP);
        break;
    }
    return true;
}

class Game extends SurfaceView implements Runnable
{
    private Thread            renderThread = null;
    private SurfaceHolder     holder;
    private volatile boolean  running = false;  

    private int  x  = 0,y = 0;
    private int  xx = 250;
    private int  xy = 400;

    public Game(Context context)
    {
        super(context);

        holder = getHolder();   
    }

    public void resume() 
    {
        running      = true;
        renderThread = new Thread(this);

        renderThread.start();
    }

    public void run() 
    {
        while(running) 
        {
            if(!holder.getSurface().isValid())
            {
                continue;
            }

            //
            // Update Scene
            //


            //
            // Render scene
            //

            graphicsMan.beginScene(holder);
            graphicsMan.clearScene();   
            x = inputMan.getRelativeX();
            y = inputMan.getRelativeY();
            if(inputMan.getTouchState() == InputManager.TOUCH_MOVE)
            {
                xx += x;
                xy += y;
            }
            graphicsMan.drawText(0, "X", Color.RED,40,xx, xy);
            graphicsMan.endScene(holder);
        }
    }

    public void pause() 
    {
        running = false;

        while(true) 
        {
            try 
            {
                renderThread.join();
            } 
            catch (InterruptedException e)
            {
                // retry
            }
        }
    }
}
}
</code></pre>
