android - Admob Interstitial Time Showing -


i have big problem in game admob interstitials. ad shown when timer finished or when player exit round. @ finish of activity. when there isn't connection, it's ok. change of activity fast. when there god , fast connection same. problem when there worth connection , when player finish round, there long time (sometimes ad never shown) activity don't change, player can continue play tough time over. code:

public void ondismissscreen(ad arg0) {     // todo auto-generated method stub  }  public void onfailedtoreceivead(ad arg0, errorcode arg1) {      intent data = new intent();     data.putextra("team", team);     mydb.close();     data.putextra("a", a);     data.putextra("b", b);     // data.putextra("contadb", this.contdb);     setresult(1, data);     finish();  }  public void onleaveapplication1(ad arg0) {     // todo auto-generated method stub  }  public void onpresentscreen1(ad arg0) {     // todo auto-generated method stub  }  public void onreceivead(ad ad) {     log.d("ok", "received ad");     if (ad == interstitial) {         if(ad.isready())            interstitial.show();     }      intent data = new intent();     data.putextra("team", team);     mydb.close();      data.putextra("a", a);     data.putextra("b", b);     // data.putextra("contadb", this.contdb);     setresult(1, data);     finish(); }  public void ondismissscreen1(ad arg0) {     // todo auto-generated method stub  }  public void onleaveapplication(ad arg0) {     // todo auto-generated method stub  }  public void onpresentscreen(ad arg0) {     // todo auto-generated method stub  } 

and:

public boolean isonline() {     connectivitymanager cm = (connectivitymanager)             .getsystemservice(context.connectivity_service);     networkinfo ni = cm.getactivenetworkinfo();     if (ni == null)         return false;      return ni.isconnected(); }  public void visualizzarisultatoactivity() {     if (isonline()) {         interstitial = new interstitialad(this, "0976ebb3525a494a");         // create ad request         adrequest adrequest = new adrequest();         // begin loading interstitial         interstitial.loadad(adrequest);         // set ad listener use callbacks below         interstitial.setadlistener(this);     } else {         intent data = new intent();         data.putextra("team", team);         mydb.close();         data.putextra("a", a);         data.putextra("b", b);         // data.putextra("contadb", this.contdb);         setresult(1, data);         finish();     }  } 

visualizzarisultatoactivity called when time finished or player cancel round. in advance

the best practice preload interstitial during game, , polling if it's ready @ end of game:

if(interstitial.isready()) {   interstitial.show(); } 

the isready flag gets set when interstitial calls onreceivead, can wait show until end of game. note should request/show interstitial within game activity, instead of visualizzarisultatoactivity. interstitial expected shown same activity passed constructor.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -