3
\$\begingroup\$

I am trying to reward a user a point whenever they watch/look at an ad. I give the user the reward whenever they watch the ad. However, the user earns a point even if they go to the ad and click back:

 mInterstitialAd.setAdListener(new AdListener() {
            @Override
            public void onAdClosed() {
                giveUserPoint();
                }
            }
        });

Is there a way I can see if the user clicked the back button while the ad was opened?

Maybe something like:

userBackClickListener(){
    if(adIsOpen){
     dontGiveUserPoint();
    }
}

How can I see if the ad was open while an action happened?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You should include information about the way you are displaying the ads. Maybe the ad SDK has some option to check if the ad was fully watched? \$\endgroup\$ Commented Nov 18, 2016 at 12:05

2 Answers 2

1
\$\begingroup\$

In onAdClosed() you need to check if the user has watched the ad.

public void onAdClosed() {
        if(adFinishedPlaying()) {
            giveUserPoint();
        }
    }
}

You'll need to write the adFinishedPlaying method, which will depend on how you're showing the ad to the user. If it's a video ad you could check the position against the duration or for picture ads you could use a timer.

// Example
private boolean adFinishedPlaying() {
    boolean finished;
    // If the ad is a video ad, check if it is finished playing.
    if ( ad.isVideo() ) {
        finished = ad.position >= ad.duration;
    }
    // Else, check if the user has looked at it for long enough.
    else {
        finished = (time.now() - ad.startTime) >= ad.duration;
    }
    return finished;
}

The above is only a rough example; The implementation will depend heavily on what tools your using to display your ads.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I know that, but how do I know if the user actually watched it? What would the method 'adFinishedPlaying' consist of? That is not a native method...we must make it \$\endgroup\$ Commented Apr 8, 2016 at 17:21
  • \$\begingroup\$ As Alex already said, this will depend on which tool you use to display your ads. \$\endgroup\$ Commented Nov 18, 2016 at 12:05
-1
\$\begingroup\$

Set a timer of 3 seconds or so? Maybe it has something with time. Count how much time he is not in the app

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .