我正在制作一款我想要广告的Android游戏(免费版本,而不是付费广告),但我无法让它正常工作,它会显示一个看起来像广告的矩形,用红色表示:你必须在AndroidManifest.xml中使用configChanges声明AdActivity。但我知道了。请帮助我,并提前感谢!看看我的代码:
的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mysoftwaremobileapps.ParachuteHunterLite"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".ParachutehunterActivity" android:screenOrientation="portrait" android:configChanges="orientation">
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/app_name" android:name=".GameScreenActivity" android:screenOrientation="portrait" android:configChanges="orientation"></activity>
<activity android:name=".playerLostMessageActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="orientation"></activity>
<activity android:name="com.mysoftwaremobileapps.ParachuteHunterLite.SubmitScoreActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="orientation"></activity><activity android:name="com.google.ads.AdActivity" android:configChanges="orientation"></activity>
<activity android:configChanges="keyboard|keyboardHidden|orientation" android:label="@string/app_name" android:name=".AdActivity" android:screenOrientation="portrait"></activity>
<activity android:configChanges="keyboard|keyboardHidden|orientation" android:name="com.google.ads.AdActivity"><meta-data android:value="Number" android:name="ADMOB_PUBLISHER_ID" /></activity>
</application>
</manifest>
添加AdView的代码:
LinearLayout parent = (LinearLayout) findViewById(R.id.MainLayout3);
AdView ad = new AdView(this, AdSize.BANNER, "a14d91b10f12454");
parent.addView(ad);
AdRequest r = new AdRequest();
ad.loadAd(r);
答案 0 :(得分:0)
有关名称,请尝试
android:name="com.google.ads.AddActivity"
如果这不起作用,那么另一个关于AdsActivity的问题可能有所帮助(这就是我得到上述内容的地方):