我已在清单中包含相关部分:
<meta-data android:value="123456789" android:name="ADMOB_PUBLISHER_ID" />
<!-- Track Market installs from AdMob ads -->
<receiver android:name="com.admob.android.ads.analytics.InstallReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />'
和
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>'
attrs 从示例中复制:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="com.admob.android.ads.AdView">
<attr name="backgroundColor" format="color" />
<attr name="primaryTextColor" format="color" />
<attr name="secondaryTextColor" format="color" />
<attr name="keywords" format="string" />
<attr name="refreshInterval" format="integer" />
</declare-styleable>
</resources>
我的布局(顺便说一句,这是一个选项卡视图)是一个表格,它在自己的行上:
xmlns:app="http://schemas.android.com/apk/res/com.icukansas.lenscalculator"
和
<TableRow>
<!-- Place an AdMob ad at the bottom of the screen. -->
<!-- It has white text on a black background. -->
<com.admob.android.ads.AdView
android:layout_span="4"
android:id="@+id/ad"
app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF"
app:secondaryTextColor="#CCCCCC"
app:keywords="security"
/>
</TableRow>
然后我打电话给:
public class myClass extends Activity implements AdListener{
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.tab_thistab);
AdView ad = (AdView) findViewById(R.id.ad);
ad.setAdListener(this);
每次我在日志中收到 onFailedToReceiveAd 错误。
我敢肯定它很容易我想念:)