2013-12-12 143 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