Kec
Kec

Reputation: 1445

Android Admob - How to declare AdActivity in Manifest

I try to create simple example for AdMob but I failed. This is my source code

AdMobActivity

public class AdMobActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
  }
}

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/linearLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.google.ads.AdView android:id="@+id/adView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         ads:adUnitId="myId"
         ads:adSize="BANNER"
         ads:loadAdOnCreate="true" />
</LinearLayout>

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.ad.mob"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".AdMobActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
            <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
</manifest>

I use AdMob 4.3.1 and for Android target=android-13

When I try to execute project, in place where my add needs to be is message: "You must have AdActivity declared in AndroidManifest.xml with configChanges". So where is my mistake here?

Upvotes: 2

Views: 12680

Answers (2)

YuriK
YuriK

Reputation: 432

And full answer for those using modern adMob from Google Mobile Services should be:

<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

(note, that android:name changed)

Upvotes: 1

Cristian
Cristian

Reputation: 200090

AdActivity must have these config changes:

keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize

Upvotes: 4

Related Questions