我已在我的应用程序中实现了MobFox。
我有两个问题。
即使在测试模式下,首先广告无法加载(bannerLoadFailed),然后我看到它(bannerLoadSucceeded)。这是由onResume()方法引起的。没有它,加载就没有失败。为什么呢?
它不显示任何广告。在测试模式下,它显示测试广告,无论是在模拟器中还是从市场下载,但在实时模式下,noAdFound()
方法处于活动状态,在吐司中说“没有发现MobFox广告”。
根据文件
noAdFound表示广告目前没有可用的广告 请求
我来自匈牙利,但是一位朋友在奥地利下载了应用程序,MobFox总部在那里,所以我怀疑奥地利没有广告请求......
MobFox信息中心显示3次展示,我不知道他们是否来自测试广告。如果他们来自真实广告,问题2是可以忽略的,但我仍然不知道为什么我的朋友看不到任何广告。
请您查看代码以查看可能导致问题的原因(是否存在问题)?
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MobFoxlayout = (RelativeLayout)findViewById(R.id.mobfoxContent);
mobfoxView = new MobFoxView(Main.this, "211bcbf66f79c0355e43e849aec76b6c", Mode.LIVE, true, true);
mobfoxView.setBannerListener(new BannerListener() {
@Override
public void bannerLoadFailed(RequestException cause) {
Toast.makeText(getApplicationContext(), "Mobfox ad failed ", Toast.LENGTH_SHORT).show();
}
@Override
public void noAdFound() {
Toast.makeText(getApplicationContext(), "No MobFox ad Found", Toast.LENGTH_SHORT).show();
}
@Override
public void bannerLoadSucceeded() {
Toast.makeText(getApplicationContext(), "MobFox Ad loaded successfully", Toast.LENGTH_SHORT).show();
}
@Override
public void adClicked() {
Toast.makeText(getApplicationContext(), "MobFox Ad clicked", Toast.LENGTH_SHORT).show();
}
});
MobFoxlayout.addView(mobfoxView);
}
@Override
protected void onResume() { //ad fails to load
super.onResume();
mobfoxView.resume();
}
@Override
protected void onPause() {
super.onPause();
mobfoxView.pause();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mobfoxView.pause();
mobfoxView.resume();
}
答案 0 :(得分:1)
我不知道出了什么问题,但它确实有效。我发布了整个代码供其他人帮忙。这段代码的重要部分是我设法在MobFox广告失败时显示admob广告!
重要的是,如果您将MobFox广告切换到测试模式,您将在模拟器中看到测试广告。在我的手机上,我没有看到任何实时或测试广告,但我在MobFox仪表板上看到了很多印象。有时候我也没有看到任何混合广告。在我的手机上我常常看到它们,在我兄弟的手机上我们从未见过它们。但他们在那里考虑我从他们那里赚钱。
public class MainActivity extends Activity {
//MOBFOX----------------------------
private RelativeLayout rlayout;
private MobFoxView mobfoxView;
//ADMOB-----------------------------
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
final Handler updateHandler = new Handler();
rlayout = (RelativeLayout) findViewById(R.id.mobfoxContent);
mobfoxView = new MobFoxView(MainActivity.this, "37a12617ccdc6bd4bafdded4e8441bca", Mode.LIVE, false, false);
mobfoxView.setBannerListener(new BannerListener() {
@Override
public void bannerLoadFailed(RequestException cause) {
//Toast.makeText(getApplicationContext(), "MobFox failed", Toast.LENGTH_LONG).show();
adView = new AdView(MainActivity.this, AdSize.BANNER, MY_AD_UNIT_ID);
LinearLayout layout = (LinearLayout)findViewById(R.id.admobContent);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
@Override
public void noAdFound() {
//Toast.makeText(getApplicationContext(), "MobFox noAd", Toast.LENGTH_LONG).show();
adView = new AdView(MainActivity.this, AdSize.BANNER, MY_AD_UNIT_ID);
LinearLayout layout = (LinearLayout)findViewById(R.id.admobContent);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
@Override
public void adClicked() {
//Toast.makeText(getApplicationContext(), "MobFox clicked", Toast.LENGTH_LONG).show();
// TODO Auto-generated method stub
}
@Override
public void bannerLoadSucceeded() {
//Toast.makeText(getApplicationContext(), "MobFox success", Toast.LENGTH_LONG).show();
// TODO Auto-generated method stub
}
});
mobfoxView.setVisibility(View.VISIBLE);
mobfoxView.setOnClickListener(new android.view.View.OnClickListener(){
@Override
public void onClick(View v) {
updateHandler.post(new Runnable() {
public void run() {
//Toast.makeText(getApplicationContext(), "MobFox clicked2", Toast.LENGTH_LONG).show();
}
});
}});
rlayout.addView(mobfoxView);
}
@Override
protected void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
//mManager.release();
}
@Override
protected void onPause() {
super.onPause();
mobfoxView.pause();
}
@Override
protected void onResume() {
super.onResume();
mobfoxView.resume();
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_selector"
android:orientation="vertical" >
<!-- objects -->
<LinearLayout
android:id="@+id/admobContent"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="50dp">
</LinearLayout>
<RelativeLayout
android:id="@+id/mobfoxContent"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
不要忘记这些布局文件夹!