gpt4 book ai didi

java - Admob - 没有广告可显示

转载 作者:IT老高 更新时间:2023-10-28 23:35:26 26 4
gpt4 key购买 nike

你好我尝试制作一些在 Android 手机上展示广告的示例程序,并尝试在 v2.2 的 Emulator 上对其进行测试代码中的一切似乎都很好,但调试器中的 AdListener 说:

Response message is zero or null;
onFailedToReceiveAd( No ad to show).

有什么办法可以让我错吗?有没有人遇到同样的问题?这是代码 list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AdTest"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AdTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- AdMobActivity definition -->
<activity android:name="com.google.ads.AdActivity"
android:configChanges="orientation|keyboard|keyboardHidden" />
</application>
<uses-sdk android:minSdkVersion="7"></uses-sdk>
<!-- AdMob SDK requires Internet permission -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

布局xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>

和 Activity 代码

package com.AdTest;
import com.google.ads.*;
import com.google.ads.AdRequest.ErrorCode;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;

public class AdTest extends Activity implements AdListener{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout layout = (LinearLayout)findViewById(R.id.main);
AdView adView = new AdView(this, AdSize.BANNER, "anonymouse");
// Unit ID is correct, I changed it on purpose while pasting here
adView.setAdListener(this);
layout.addView(adView);
AdRequest request= new AdRequest();
adView.loadAd(request);
}

public void onFailedToReceiveAd(AdView adView)
{
Log.d("AdListener", "onFailedToReceiveAd");
}

public void onFailedToReceiveRefreshedAd(AdView adView)
{
Log.d("AdListener", "onFailedToReceiveRefreshedAd");
}

public void onReceiveAd(AdView adView)
{
Log.d("AdListener", "onReceiveAd");
}

public void onReceiveRefreshedAd(AdView adView)
{
Log.d("AdListener", "onReceiveRefreshedAd");
}

@Override
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub

}

@Override
public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1) {
Log.d("AdListener", "onFailedToReceiveAD");

}

@Override
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub

}

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

}

@Override
public void onReceiveAd(Ad arg0) {
Log.d("AdListener", "Received succesfully");

}
}

最佳答案

我遇到了同样的问题

onFailedToReceiveAd( No ad to show).

由于某些原因,AdMob 似乎没有为我们的应用发送广告内容。即使我处于测试模式,仍然没有广告。

我在 AdMob 上制作了自家广告来验证我的申请。这是一种比测试模式更容易的开发方式。

关于java - Admob - 没有广告可显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5350933/

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