0

我已经开始将 Airpushes 横幅广告“AdView”集成到我的应用程序中并使其运行良好,但是我知道如果用户购买了我的捐赠密钥,我希望能够禁用广告,我已经设置好了,如果用户通过共享偏好拥有密钥。

但是,当我执行以下操作时,广告仍然显示,在我的 oncreate 中我有:

AdView ad = (AdView) findViewById(R.id.guideAdView);
        if (AppPreferences.getPrefs().getBoolean("full", false)){
            ad.setVisibility(View.GONE);
        }

        AdCallbackListener adCallbackListener = new AdCallbackListener() {

            @Override
            public void onSDKIntegrationError(String message) {
                // Here you will receive message from SDK if it detects any
                // integration issue.
            }

            public void onSmartWallAdShowing() {
                // This will be called by SDK when it’s showing any of the
                // SmartWall ad.
            }

            @Override
            public void onSmartWallAdClosed() {
                // This will be called by SDK when the SmartWall ad is closed.
            }

            @Override
            public void onAdError(String message) {
                // This will get called if any error occurred during ad serving.
            }

            @Override
            public void onAdCached(AdType arg0) {
                // This will get called when an ad is cached.

            }

            @Override
            public void onVideoAdFinished() {
                // TODO Auto-generated method stub

            }

            @Override
            public void onVideoAdShowing() {
                // TODO Auto-generated method stub

            }
        };

        if (airPlay == null)
            airPlay = new AirPlay(this, adCallbackListener, false); 

我知道if (AppPreferences.getPrefs().getBoolean("full", false))工作正常,因为如果用户确实拥有完整的密钥,则在活动中的其他地方使用它来显示其他信息。所以问题是为什么上面的内容对 adView 不起作用?

4

1 回答 1

0

我从未使用过 airpush,但如果用户有密钥,为什么不直接运行广告代码。

如果不显示广告,则设置所有侦听器和新 AirPlay 对象是没有意义的。

例如:

    if (AppPreferences.getPrefs().getBoolean("full", false)){
        // Do not show ads
        AdView ad = (AdView) findViewById(R.id.guideAdView);    
        ad.setVisibility(View.GONE);
    } else {
        // Show Ads
        // Set up listener (omitted from this example for clarity)
        if (airPlay == null) airPlay = new AirPlay(this, adCallbackListener, false); 
    }
于 2013-12-02T22:06:28.527 回答