我在我的应用中实施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.
有谁知道为什么会这样?
答案 0 :(得分:1)
首先,“ads.domain.com”是未知域名。是OpenX ready服务器吗?尝试调查演示应用控制台日志以获取更多详细信息。
答案 1 :(得分:0)
另一件要问的是你的旗帜在哪里?没有它,控制器没有显示任何内容。你应该有这样的东西:
@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);
}
}