gpt4 book ai didi

ios - 使用 iOS RoboVM/libgdx 检测 AdMob 中插页式广告的关闭

转载 作者:可可西里 更新时间:2023-11-01 05:34:09 25 4
gpt4 key购买 nike

我正在为我的 iOS 应用程序使用 RoboVM 绑定(bind)来显示 AdMob 插页式广告。当我关闭插页式广告时,我失去了所有的触摸控制。有没有办法检测广告是否已关闭,以便我可以将触摸恢复到游戏中?或者有更好的方法来实现插页式广告吗?下面是我的代码:

public class IOSLauncher extends IOSApplication.Delegate implements IActivityRequestHandler{
private static final Logger log = new Logger(IOSLauncher.class.getName(), Application.LOG_DEBUG);
private IOSApplication iosApplication;

//interstitial
private static final String INTERSTITIAL_AD = "MY_AD_ID";
private GADInterstitial interstitial;
private UIWindow window;
private UIViewController rootViewController;

@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
config.orientationLandscape = true;
config.orientationPortrait = false;

iosApplication = new IOSApplication(new PaperPig(this), config);
return iosApplication;
}

public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
UIApplication.main(argv, null, IOSLauncher.class);
pool.close();
}

@Override
public void initializeAds() {
intializeInterstitial();
}

public void intializeInterstitial () {
rootViewController = new UIViewController();

interstitial = new GADInterstitial();
interstitial.setAdUnitID(INTERSTITIAL_AD);

interstitial.setDelegate(new GADInterstitialDelegateAdapter() {
@Override
public void didReceiveAd (GADInterstitial ad) {
System.out.println("Did receive ad.");
}

@Override
public void didFailToReceiveAd (GADInterstitial ad, GADRequestError error) {
System.out.println(error.description());
System.out.println(error.getErrorCode());
}
});

window = new UIWindow(UIScreen.getMainScreen().getBounds());
window.setRootViewController(rootViewController);
window.addSubview(rootViewController.getView());

interstitial.loadRequest(GADRequest.create());
}

@Override
public void showOrLoadInterstital() {
if (interstitial.isReady()) {
if (rootViewController == null) {
rootViewController = new UIViewController();
}
if (window == null) {
window = new UIWindow(UIScreen.getMainScreen().getBounds());
window.setRootViewController(rootViewController);
}
window.makeKeyAndVisible();
interstitial.present(rootViewController);
}

//将触摸返回到游戏
//UIApplication.getSharedApplication().getKeyWindow().setRootViewController(rootViewController); }

最佳答案

您需要调用:

        window.setHidden(true);

将 GADInterstitialDelegateAdapter() 的创建更改为以下内容

   interstitial.setDelegate(new GADInterstitialDelegateAdapter() {
@Override
public void didReceiveAd (GADInterstitial ad) {
System.out.println("Did receive ad.");

}

@Override
public void didDismissScreen(GADInterstitial ad) {
window.setHidden(true);
}

@Override
public void didFailToReceiveAd (GADInterstitial ad, GADRequestError error) {
System.out.println(error.description());
System.out.println(error.getErrorCode());
}
});

关于ios - 使用 iOS RoboVM/libgdx 检测 AdMob 中插页式广告的关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26528977/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com