2013-12-12 145 views
1

我需要在活动A上显示DoubleClick插页式广告,并在活动B上显示简单的DoubleClick横幅,并且我需要仅在3秒内显示插页式广告,然后转到活动B(如果使用不会点击插页式广告关闭按钮)。如何停止DoubleClick插页式广告

两者间质和旗帜正在显示正常,当我在等待这些3秒预期:在这种情况下,在活动B的简单的横幅已经不上的活动B显示,我得到这个日志:

loadAd叫而在插页或登陆页面,所以中止

似乎正确“显示关闭”的插页通过onDismissScreen功能的唯一途径,但我不能这样做,无论是。

我的代码是这样的一个

@Override 
public void onPresentScreen(Ad ad) 
{ 
    if (ad == interstitial_ad) 
    { 
     // 3-second timer 
     Handler handler = new Handler(); 
     handler.postDelayed(new Runnable() 
     { 
      public void run() 
      { 
       startActivity(new Intent("Activity B")); 
      } 
     }, 3000); 
    } 
} 

我已经尝试过所有这些可能性

if (interstitial_ad != null) 
{ 
    interstitial_ad.stopLoading(); 
    interstitial_ad.loadAd(null); 
    interstitial_ad.setAdListener(null); 
    interstitial_ad = null; 
} 

,并没有什么作品。

任何线索?

在此先感谢。

回答

0

首先,在您的run()方法,开始你的活动是这样的:

Intent intent = new Intent(this, ActivityB.class); //<----whatever file Activity B resides in 
startActivity(intent); 
finish(); //<---add this to close the current activity 

接下来,在短短startActivity()后,添加完成()。您可能仍会尝试阻止您的插页式广告。

+0

我已经试过这个,它也不起作用。 – thomaus

+0

您正在使用哪个广告网络? – Melquiades