1

我正在集成AppLovin sdk以在我的应用程序中集成广告。我的应用程序是一个游戏应用程序,我希望我的用户在点击广告时奖励硬币。但 AppLovin 的 adclicklistener 似乎不适用于我的情况。

编码:

 private AppLovinAdView adView;
    // Create AppLovin Ad View
                    final AppLovinSdk sdk = AppLovinSdk.getInstance(SceneActivity.this);
                    adView = new AppLovinAdView(sdk, AppLovinAdSize.INTERSTITIAL, SceneActivity.this);

                    //Show ad after 4 levels
                    if (currentLevel % 4 == 0) {
                            // An ad is available to display.  It's safe to call show.
                            AppLovinInterstitialAd.show(SceneActivity.this);
                            adView.loadNextAd();

                    }


                    adView.setAdClickListener(new AppLovinAdClickListener() {
                        @SuppressLint("SimpleDateFormat")
                        @Override
                        public void adClicked(AppLovinAd arg0)
                        {
                            System.out.println("Adclicked");
                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                            String today = sdf.format(new Date());
                            if (!today.equalsIgnoreCase(getLastDownloadDate())) {
                                // give coins once per day
                                modifyMoney(MONEY_DOWNLOAD_GAME);

                                // put last Download date
                                setLastDownloadDate(today);
                            }
                        }
                        });

INTERSTITIAL 广告正在展示,但点击监听器不起作用。

4

1 回答 1

2

问题是您正在混合AppLovinInterstitialAd(内部拥有自己的实例AppLovinAdView)和您自己的独立AppLovinAdView。当您调用 时AppLovinInterstitialAd.show(),您将绕过附加了侦听器的广告视图。

所以你根本不需要使用AppLovinAdView......试试这个:

private void showInterstitial() {

    final AppLovinSdk sdk = AppLovinSdk.getInstance(mActivity);
    final AppLovinInterstitialAdDialog adDialog = AppLovinInterstitialAd.create(sdk, mActivity);

    adDialog.setAdClickListener(new AppLovinAdClickListener() {
        @Override
        public void adClicked(AppLovinAd appLovinAd) {
            // Ad clicked, add your on-click logic here
        }
    });

    adDialog.show(); // Display a pre-cached interstitial
}
于 2015-06-22T18:09:59.410 回答