0

我在我的应用程序中实现 OpenX 时遇到问题。这就是我设置 OXMAdController 的方式:

protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    //OpenX init (needs to be called before setContentView method)
    OXMManagersResolver.getInstance().prepare(this);

    setContentView(R.layout.category_pager);    

    //Setting OpenX
    try
    {
        mAdController = new OXMAdController(this, "ads.domain.com");
    }
    catch (OXMAndroidSDKVersionNotSupported e) 
    {
        e.printStackTrace();
    }

    mAdController.setAdControllerEventsListener(new OXMAdControllerEventsListener() 
    {
        @Override
        public void adControllerWillLoadAd(OXMAdBaseController arg0) 
        {
            Log.v("test", "adControllerWillLoadAd");
        }

        @Override
        public void adControllerDidLoadAd(OXMAdBaseController arg0) 
        {
            Log.v("test", "adControllerDidLoadAd");
        }

        @Override
        public void adControllerDidFailWithNonCriticalError(OXMAdBaseController arg0, OXMError arg1) 
        {
            Log.v("test", "adControllerDidLoadAd");
        }

        @Override
        public void adControllerDidFailToReceiveAdWithError(OXMAdBaseController arg0, Throwable arg1) 
        {
            Log.v("test", "adControllerDidFailToReceiveAdWithError");
        }

        @Override
        public void adControllerActionUnableToBegin(OXMAdBaseController arg0) 
        {
            Log.v("test", "adControllerActionUnableToBegin");
        }

        @Override
        public boolean adControllerActionShouldBegin(OXMAdBaseController arg0, boolean arg1) 
        {
            Log.v("test", "adControllerActionShouldBegin");
            return true;
        }

        @Override
        public void adControllerActionDidFinish(OXMAdBaseController arg0) 
        {
            Log.v("test", "adControllerActionDidFinish");
        }
    });

    mAdController.initForAdUnitIds(43, 43);
    mAdController.startLoading();
}

服务器返回回调方法adControllerDidFailToReceiveAdWithError两次。第一次错误是com.openx.ad.mobile.sdk.errors.OXMServerWrongStatusCode: Server returned 404 status code,第二次错误是com.openx.ad.mobile.sdk.errors.OXMServerWrongResponse: Server response parsing error.

有谁知道为什么会这样?

4

2 回答 2

1

首先,“ads.domain.com”是未知域。它是 OpenX 就绪的服务器吗?尝试调查演示应用程序控制台日志以获取更多详细信息。

于 2012-10-06T14:50:40.263 回答
0

另外要问的是你的banner在哪里?没有它,控制器不会显示任何内容。你应该有这样的东西:

           @Override
            public void adControllerWillLoadAd(OXMAdBaseController c) {
                Log.w(HangApp.TAG, "adControllerWillLoadAd");
                RelativeLayout parent = (RelativeLayout) findViewById(R.id.ad_parent);
                OXMAdBannerView view = mAdController.getAdBannerView();

                if (view != null) {
                    findViewById(R.id.ad_image).setVisibility(View.GONE);
                    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0);
                    view.presentAdInViewGroup(parent, layoutParams);
                }
            }
于 2013-08-15T19:20:33.837 回答