Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Apr 2014
    Posts
    79
    Post Thanks / Like
    Mentioned
    4 Post(s)

    Help with coding exit Ads

    Hi to everyone,
    i am a wannabe developer and quite unexperienced with programming so maybe this question may seem stupid to many of you, but i have been struggling for days and can't find how to do it.

    I managed to setup correctly a unity3d admob plugin (this: https://github.com/nabrozidhs/unity_admob_android) and to get it to work so that it displays the banner only when i want it.

    My problem comes with the interstitial...i tested it and it is also working, but i can't find a way to make it appear when the user leave the application, either by pressing the home button (the back button is used to go back to main menu in my game) or by pressing the quit button i provide in the different scenes.

    I tried to call the admob.showinterstitial under void onApplicationQuit and also onDestroy and, in both cases, i have the ad correctly appear.... but then it automatically closes up after 1-2s (i imagine as soon as the app is completely closed).
    In both cases, also, the interstitial appears only when i use my ingame quit button (which does application.quit) but not when pressing the home button on the phone.

    I've read many people saying that they use interstitial ads on app exit, so it is doable for sure.....but can anyone tell me how to do it please?

  2. #2
    Member Mateusz's Avatar
    Join Date
    Mar 2014
    Posts
    387
    Post Thanks / Like
    Mentioned
    10 Post(s)
    your activity can listen for every button pressed.

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if(keyCode == KeyEvent.KEYCODE_BACK){
    //do smth
    }
    else if(keyCode == KeyEvent.KEYCODE_MENU){
    //do smth
    }
    return false;
    }

    then u display loaded interstial. And close the application only after user close the ap or hit the back button again (hitting back button is easier than clicking X but maybe some ppl will click ad instead. Is it ok guys? )
    your interstial has event on Close. Look on example:


    public void displayInterstitialAndExit() {
    this.runOnUiThread(new Runnable() {
    @Override
    public void run() {
    interstitial.setAdListener(new AdListener() {
    @Override
    public void onAdClosed() {
    super.onAdClosed();
    finish();
    System.exit(0);
    }
    });

    if (interstitial.isLoaded()) {
    interstitial.show();
    }
    else{
    System.out.println("No interestitial loaded");
    finish();
    System.exit(0);
    }

    }
    });
    }


    bad code formating but probably u get the point

  3. #3
    Member
    Join Date
    Apr 2014
    Posts
    79
    Post Thanks / Like
    Mentioned
    4 Post(s)
    thx, i will try to do that....even though it seems the plugin i am using doesn't have a listener, so i guess i'll have to learn how to code my own banners

  4. #4
    Member Mateusz's Avatar
    Join Date
    Mar 2014
    Posts
    387
    Post Thanks / Like
    Mentioned
    10 Post(s)
    if you use admob and google play sdk you should have the same what i have

Similar Threads

  1. Showing Ads on Exit
    By ThemeBowlApp in forum Android Development
    Replies: 7
    Last Post: 2014-03-15, 08:58 AM
  2. AppWiz exit-ads
    By vbodzio in forum Advertising Networks
    Replies: 7
    Last Post: 2013-10-04, 04:05 PM
  3. Exit Ads + MoPub. Is it possible?
    By proph in forum Advertising Networks
    Replies: 0
    Last Post: 2013-09-21, 08:23 PM
  4. Good network for exit ads?
    By tpjackson in forum Advertising Networks
    Replies: 4
    Last Post: 2013-09-11, 03:34 PM
  5. Question about StartApp exit-ads
    By Beppi in forum Advertising Networks
    Replies: 5
    Last Post: 2013-06-10, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •