Search code examples
androidfullscreenadsonresume

How to fix onResume/onRestart fullscreen ad?


I'm trying to insert a full-screen ad, following the guide provided by my network. this is the guide

and this is my code

private RevMob revmob;
private RevMobFullscreen fullscreen;

protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.episodi_activity);

    revmob = RevMob.start(this);
    fullscreen = revmob.createFullscreen(this, null);
}
protected void onRestart [or onResume :)] () {
    super.onRestart ();
    fullscreen.show ();
}

the full-screen ad work but only for the first onRestart or onResume, subsequent ones, nothing happens. How can I solve this problem? (show full-screen to "every" time start the onRestart or onResume methods.

thank you.


Solution

  • I Used this code successfully.
    In oncreate used the following code

        revmob = RevMob.start(this, "your ad id");
        revmob.printEnvironmentInformation(this);
        revmob.setTestingMode(RevMobTestingMode.WITH_ADS);
        revmob.createFullscreen(this, revmobListener);
        revmob.showFullscreen(this);
        revmob.setTimeoutInSeconds(5);
    

    and used the following method

    public void onStart() {
            super.onStart();
              revmobListener = new RevMobAdsListener() {
             @Override
             public void onRevMobAdDisplayed() {
                 Log.i("[RevMob]", "onAdDisplayed");
             }
    
         @Override
         public void onRevMobAdReceived() {
             Log.i("[RevMob]", "onAdReceived");
    
         }
    
         @Override
         public void onRevMobAdNotReceived(String message) {
             Log.i("[RevMob]", "onAdNotReceived");
         }
    
         @Override
         public void onRevMobAdDismiss() {
             Log.i("[RevMob]", "onAdDismiss");
         }
    
         @Override
         public void onRevMobAdClicked() {
             Log.i("[RevMob]", "onAdClicked");
         }
     };
    }
    
    public void showFullscreen(View view) {
     RevMobFullscreen fs = revmob.createFullscreen(this, revmobListener);
     fs.show();
    
    }
    

    This Code worked fine for me.