Alexandru Circus
Alexandru Circus

Reputation: 5538

AdView how to "hold" ads loading

I have a ViewPager with 2 screen on it. You can swipe to navigate between these 2 fragments. One of the fragments contains ads at the bottom.

The problem is when I navigate from the ads fragment to the other one(ads screen not visible now) ads ARE STILL LOADING!!!! and this cause a very low CTR since they are loading but are not visible to user.

Here is some paste from console when the ads screen is not visible:

10-29 23:03:32.955: I/Ads(10391): Starting ad request.
10-29 23:03:32.965: I/Ads(10391): Use AdRequest.Builder.addTestDevice("FE742438514BB5FC16E661BDF9966519") to get test ads on this device.
10-29 23:03:32.975: I/Ads(10391): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
10-29 23:03:33.566: I/Ads(10391): Ad is not visible. Not refreshing ad.
10-29 23:03:33.566: I/Ads(10391): Scheduling ad refresh 60000 milliseconds from now.
10-29 23:03:34.166: I/Ads(10391): Scheduling ad refresh 55000 milliseconds from now.
10-29 23:03:34.176: I/Ads(10391): Ad finished loading.
10-29 23:03:42.565: I/Ads(10391): Ad is not visible. Not refreshing ad.
10-29 23:03:42.565: I/Ads(10391): Scheduling ad refresh 60000 milliseconds from now.
10-29 23:04:01.553: I/Ads(10391): Ad is not visible. Not refreshing ad.
10-29 23:04:01.553: I/Ads(10391): Scheduling ad refresh 60000 milliseconds from now.
10-29 23:04:29.170: I/Ads(10391): Starting ad request.
10-29 23:04:29.170: I/Ads(10391): Use AdRequest.Builder.addTestDevice("FE742438514BB5FC16E661BDF9966519") to get test ads on this device.
10-29 23:04:29.180: I/Ads(10391): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
10-29 23:04:30.491: I/Ads(10391): Scheduling ad refresh 55000 milliseconds from now.
10-29 23:04:30.491: I/Ads(10391): Ad finished loading.
10-29 23:04:33.564: I/Ads(10391): Ad is not visible. Not refreshing ad.
10-29 23:04:33.564: I/Ads(10391): Scheduling ad refresh 60000 milliseconds from now.
10-29 23:04:42.563: I/Ads(10391): Ad is not visible. Not refreshing ad.
10-29 23:04:42.563: I/Ads(10391): Scheduling ad refresh 60000 milliseconds from now.
10-29 23:05:01.552: I/Ads(10391): Ad is not visible. Not refreshing ad.
10-29 23:05:01.562: I/Ads(10391): Scheduling ad refresh 60000 milliseconds from now.

ViewPage adapter code:

public class AudioRecPagerAdapter extends FragmentStatePagerAdapter {

    private ArrayList<Fragment> registeredFragments = new ArrayList<Fragment>();

    public AudioRecPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int index) {        
        Fragment fg = null;
        switch (index) {
        case 0:
            fg = new RecorderFragment();
            break;
        case 1:
            fg = new PlayerFragment();
            break;

        default:
            break;
        }

        return fg;
    }

    @Override
    public Object instantiateItem(ViewGroup arg0, int arg1) {
        Fragment fg = (Fragment)super.instantiateItem(arg0, arg1);
        registeredFragments.add(fg);
        return fg;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        registeredFragments.remove(position);
        super.destroyItem(container, position, object);
    }

    @Override
    public int getCount() {
        return 2;
    }

    public Fragment getRegisteredFragment(int position){
        return registeredFragments.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
        case 0:
            return AudioRecApplication.getInstance().getApplicationContext().getString(R.string.recorder_tab_name);
        case 1:
            return AudioRecApplication.getInstance().getApplicationContext().getString(R.string.player_tab_name);

        default:
            return super.getPageTitle(position);
        }
    }

}

Upvotes: 0

Views: 381

Answers (1)

William
William

Reputation: 20196

While the AdView is still checking whether to request an ad, the log shows that it clearly is not doing so, because the AdView is not visible. So this will not affect your CTR as the ad is never requested or displayed.

Upvotes: 1

Related Questions