0

我正在尝试将 Appodeal 横幅添加到 LibGDX 应用程序中,但横幅广告覆盖了屏幕,而不是放置在其上方。我找不到任何在 LibGDX 中使用 Appodeal 的教程,所以我正在从本教程中学习如何在 LibGDX 中使用 Admob。https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx

我不知道如何以 View 的形式获取 Appodeal 横幅广告,可以使用 addView() 方法将其添加到 RelativeLayout。我尝试了几种方法来做到这一点,它们被标记为“ATTEMPT #1”和“ATTEMPT #2”,但在这两种尝试中,横幅广告都没有显示。“Appodeal.show(this, BANNER);”这一行 将横幅放在屏幕顶部,因此被注释掉。任何帮助得到这个数字将不胜感激。谢谢。

这是我创建和显示横幅广告的 AndroidLauncher.java 文件。

public class AndroidLauncher extends AndroidApplication {
    private final int BANNER = 4;

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

        // LAYOUT: combines LibGDX View and Ad View
        RelativeLayout relativeLayout = new RelativeLayout(this);

        // Ad View
        Appodeal.initialize(this, "fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f", BANNER);
        Appodeal.setTesting(true);
//        Appodeal.show(this, BANNER);
        // ATTEMPT #1
        BannerView bannerView = Appodeal.getBannerView(this);
        // ATTEMPT #2
//        BannerView bannerView = new BannerView(this, null);
//        Appodeal.setBannerViewId(bannerView.getId());

        // LibGDX View
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);     
        View libgdxView = initializeForView(new AppodealGDXDemo(), config);

        // add to view
        relativeLayout.addView(bannerView);
        relativeLayout.addView(libgdxView);

        // set layout
        setContentView(relativeLayout);
    }
}
4

1 回答 1

0

我终于在 Appodeal 网站上找到了帮助我的信息。https://wiki.appodeal.com/en/android/2-5-8-android-sdk-integration-guide/ad-types 看来他们已经对他们的网站进行了很多更改,因为他们的文档链接我从谷歌找到的网站重定向到主页。

我现在开始工作了,这是更新的代码。

public class AndroidLauncher extends AndroidApplication {
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();

        // LAYOUT: combines LibGDX View and Ad View
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);

        // Ad View
        Appodeal.initialize(this, "fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f", Appodeal.BANNER_VIEW);
        Appodeal.setTesting(true);
        BannerView bannerView = Appodeal.getBannerView(this);
        Appodeal.show(this, Appodeal.BANNER_VIEW);

        // LibGDX View
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);     
        View libgdxView = initializeForView(new AppodealGDXDemo(), config);

        // add to layout
        layout.addView(bannerView);
        layout.addView(libgdxView);

        // set layout
        setContentView(layout);
    }
}
于 2019-09-23T15:49:44.797 回答