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