如何为适配器编写代码以从 adwhirl 中的用户定义网络获取广告

发布于 2024-12-18 02:40:31 字数 1044 浏览 3 评论 0原文

我实现了一个接口,因为它必须在成功和失败时实现 requestAdonLeaveApplicationonPresentScreenonReceiveAd。我还扩展了 AdwhirlLayout 类。我仅在 Adaptor.javarequestAd 中实现了两种方法,仅通过这些行来判断成功和失败,

public void requestAdSuccess() {
    // TODO Auto-generated method stub
    adWhirlLayout.adWhirlManager.resetRollover();
    adWhirlLayout.nextView = adView;
    adWhirlLayout.handler.post(adWhirlLayout.viewRunnable);
    adWhirlLayout.rotateThreadedDelayed();
}

public void requestAdFail() {
    // TODO Auto-generated method stub
    adView.setAdListener(null);
    adWhirlLayout.rollover();
}
public void onLeaveApplication(Ad arg0) {
    // TODO Auto-generated method stub

}

public void onPresentScreen(Ad arg0) {
    // TODO Auto-generated method stub

}

public void onReceiveAd(Ad arg0) {
    // TODO Auto-generated method stub

}

我每 15 秒刷新一次广告。我根据 adwhirl 示例中的 GoogleAdaptor.java 代码编写了此代码。我还需要在 onLeaveApplication() 中的代码中添加哪些内容?

I implemented one interface in that it has to implement requestAd on success and failure, onLeaveApplication, onPresentScreen , onReceiveAd. I also extended the AdwhirlLayout class. I implemented only two methods in Adaptor.java class requestAd on success and failure only by these lines

public void requestAdSuccess() {
    // TODO Auto-generated method stub
    adWhirlLayout.adWhirlManager.resetRollover();
    adWhirlLayout.nextView = adView;
    adWhirlLayout.handler.post(adWhirlLayout.viewRunnable);
    adWhirlLayout.rotateThreadedDelayed();
}

public void requestAdFail() {
    // TODO Auto-generated method stub
    adView.setAdListener(null);
    adWhirlLayout.rollover();
}
public void onLeaveApplication(Ad arg0) {
    // TODO Auto-generated method stub

}

public void onPresentScreen(Ad arg0) {
    // TODO Auto-generated method stub

}

public void onReceiveAd(Ad arg0) {
    // TODO Auto-generated method stub

}

I refresh my ad every 15 seconds. I wrote this based on GoogleAdAdaptor.java code in adwhirl sample. What else do I have to add to the code in onLeaveApplication()?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魔法少女 2024-12-25 02:40:31

请在此处阅读我对类似问题的回复< /a> 有关实现自定义事件的信息。

从您在此处发布的代码来看,AdWhirlLayout 没有 nextView,因此我认为 adWhirlLayout.nextView = adView; 不起作用。另外,我认为您会想要像这样发布可运行的视图:

adWhirlLayout.handler.post(new ViewAdRunnable(adWhirlLayout, adView));

据我所知,您不会错过 onLeaveApplication 中的任何内容,除非您正在使用的特定广告网络在休假时做了一些特殊的事情。

Please read my response to a similar question here for information about implementing custom events.

From the code you've posted here, AdWhirlLayout doesn't have a nextView so I don't think adWhirlLayout.nextView = adView; will work. Also, I think you will want to post the view runnable like this:

adWhirlLayout.handler.post(new ViewAdRunnable(adWhirlLayout, adView));

As far as I know, you're not missing anything in onLeaveApplication, unless the specific ad network you're working with does something special on leave.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文