I'm still new at java programming (for Android), usually I find everything that I need to know on the internet, but not this time, even if the problem doesn't seems that much complicated.

I would like to show an Ad (RevMob) when the user exits the application, an then kill the app.

If I do this, it kills the app before showing the ad:

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

  RevMob revmob = RevMob.start(this); 
  revmob.showFullscreen(this);
  android.os.Process.killProcess(android.os.Process.myPid());    
}


So it thought about waiting 10seconds before killing the app, but I don't know how to do it correctly. I tried a lot of things, like this:

public void onBackPressed() {
    super.onBackPressed();
    onBackPressedExit();

    RevMob revmob = RevMob.start(this); 
    revmob.showFullscreen(this);
}

private void onBackPressedExit() {       
    try {
        Thread.sleep(10000);
        android.os.Process.killProcess(android.os.Process.myPid());
    }
    catch(InterruptedException ie) {
    }           
}


What should I do? 
Thanks      


Question: Energy vs. Power
Answer: In physics, energy is the ability to do work (or the work done), while power is rate of energy output.  So if I push a boulder up a hill, I expend the same amount of energy regardless of how long it takes me.  However, doing it in a shorter time period requires more power.

I know you're probably not concerned with this technical distinction.  But it is good to know.  For example, now you know that it is correct to say "The car is very powerful: It can accelerate from zero to sixty in three seconds," and "It required a huge amount of energy to erect the ancient pyramids."