简体   繁体   English

Admob libgdx非页内广告

[英]Admob libgdx interstitial ads

Admob changed recently and I can't find some reliable resources on how to load interstitial ads. Admob最近发生了变化,我找不到有关如何加载非页内广告的可靠资源。 I have managed to load ads inside the main activity but I need the ad to be loaded between levels. 我已经设法在主要活动中加载广告,但是我需要在各个级别之间加载广告。 The structure is like this: main activity -> android application -> levels. 结构是这样的:主要活动-> android应用程序->关卡。 I tried to show ads by calling a method from the main app but I got an error telling me to perform this task on the UI thread. 我试图通过从主应用程序中调用方法来展示广告,但出现错误提示我要在UI线程上执行此任务。 How can you show ads from inside other classes not from the main activity? 您如何展示来自其他班级而不是主要活动中的广告? On the other hand I received "os_unix.c:30247" error and cannot open file at line 30247 of [00bb9c9ce4] although when the ad loaded on the main activity it worked. 另一方面,我收到了“ os_unix.c:30247”错误,尽管在主活动上加载了广告,它却无法在[00bb9c9ce4]的第30247行打开文件。 This is not duplicate because other questions I have found on this topic refer to legacy admob: now interstitial ads can be loaded and shown without using views. 这不是重复的,因为我在此主题上发现的其他问题都与旧版admob有关:现在,可以在不使用视图的情况下加载和展示插页式广告。

You can load/display interstitial ads in a worker/non-UI thread by using the Activity.runOnUiThread() method. 您可以使用Activity.runOnUiThread()方法在辅助线程/非UI线程中加载/显示插页式广告。 To show ads from inside other classes not from the main activity you need to use a facade. 要从其他类而不是主要活动中展示广告,您需要使用外观。

Follow this libgdx official guide . 请遵循此libgdx官方指南 It covers both banner and interstitial ads and it isn't outdated. 它涵盖了横幅广告和非页内广告,并且它已经过时了。 It uses the new admob via the google play services. 它通过Google Play服务使用新的admob。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM