0

我正在制作一个我想在上面放广告的安卓游戏(免费版本,而不是付费版本),但我无法让它正常工作,它显示一个看起来像广告的矩形,上面写着红色:你必须有 AdActivity使用 configChanges 在 AndroidManifest.xml 中声明。但我明白了。请帮助我,并提前非常感谢!看看我的代码:

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);
4

1 回答 1

0

对于名称,请尝试

android:name="com.google.ads.AddActivity"

如果这不起作用,这里有另一个关于 AdsActivity 的问题可能会有所帮助(这是我得到上述行的地方):

让 AdView 真正出现

于 2012-04-09T18:16:48.880 回答