Android - 在启动屏幕应用程序卡住后 - 可以打开广告 - 仅限Android 4.4及更高版本

时间:2014-04-23 22:29:50

标签: java android admob

我已经制作了具有启动画面的应用,在应用加载广告后,启动画面消失,广告已打开(全屏)。

它在Android 2.3到4.2上工作(为APK 8制作),但是在4.4+它被卡住了 - 它只显示了闪屏徽标但是没有移动到ad本身(在galaxy 5/4,Nexus 4/5上查看)。

顺便说一下 - 我有4.4罐子:

enter image description here

splash_screen_logo.java

public class splash_screen_logo extends Activity {
    private InterstitialAd interstitial;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash_screen_logo);

        // Create the interstitial.
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId("*****"); // deleted the id 

        // Create ad request.
        AdRequest adRequest = new AdRequest.Builder().build();

     // Begin loading your interstitial.
        interstitial.loadAd(adRequest);

        // Begin loading your interstitial.
        displayInterstitial();
        interstitial.setAdListener(new AdListener() {
            public void onAdLoaded(){
                finish();
                   displayInterstitial();

              }
            @Override
            public void onAdClosed() {
                // TODO Auto-generated method stub
                super.onAdClosed();
                Intent intent_openStartingPage = new Intent(splash_screen_logo.this, MainActivity.class);
                startActivity(intent_openStartingPage);
            }
        });
    }
    public void displayInterstitial() {
        if (interstitial.isLoaded()) {
          interstitial.show();
        }
      }
}

为什么在Android 4.4中它会卡住?

1 个答案:

答案 0 :(得分:0)

您尚未提供足够的信息来调试您的问题。但是你应该从OnAdLoaded调用interstitial.show,因为这会导致用户体验非常糟糕。

从OnAdLoaded调用完成也不是一个好主意。这意味着您的Actiivty将在您收到广告时被终止,可能在您的活动或广告有机会展示之前。

相关问题