I have a problem with admob interstitial on finish activity.
i have implemented this, i call ad on backpressed or exit pressed in-app.
public void onReceiveAd(Ad ad) {
Log.d("OK", "Received ad");
if (ad == interstitial) {
interstitial.show();
pubblicita = 1;
}
}
@Override
public void onDismissScreen(Ad arg0) {
Intent intent = new Intent(this, DiarioSegreto.class);
intent.putExtra("EXIT", true);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
this.finish();
}
@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
Intent intent = new Intent(this, DiarioSegreto.class);
intent.putExtra("EXIT", true);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
this.finish();
}
public void onBackPressed(){
// se connesso carico pubblicita'
if (isConnected) {
// Create the interstitial
interstitial = new InterstitialAd(this,
"xxx");
// Create ad request
AdRequest adRequest = new AdRequest();
// Begin loading your interstitial
interstitial.loadAd(adRequest);
// Set Ad Listener to use the callbacks below
interstitial.setAdListener(this);
} else {
Intent intent = new Intent(this, DiarioSegreto.class);
intent.putExtra("EXIT", true);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
this.finish();
}
}
but with slow connection none of these are called back and my app don't close, i need a way to close my app after few seconds of inactivity or another workaround...