Using AdMob with Games that use Open GLES

Posted by Vishal Kumar on Game Development See other posts from Game Development or by Vishal Kumar
Published on 2013-05-06T08:58:07Z Indexed on 2013/11/03 10:17 UTC
Read the original article Hit count: 470

Filed under:
|

Can anyone help me integrating Admob to my game. I've used the badlogic framework by MarioZencher ... and My game is like the SuperJumper. I am unable to use AdMob after a lot of my attempts. I am new to android dev...please help me..I went thru a number of tutorials but not getting adds displayed ...

I did the following...

  1. get the libraries and placed them properly
  2. My main.xml looks like this

    android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />

  1. My Activity class onCreate method:

    public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

    RelativeLayout layout = new RelativeLayout(this);
    adView = new AdView(this, AdSize.BANNER, "a1518637fe542a2");
    AdRequest request = new AdRequest();
    request.addTestDevice(AdRequest.TEST_EMULATOR);
    request.addTestDevice("D77E32324019F80A2CECEAAAAAAAAA");    
    adView.loadAd(request);
          layout.addView(glView);
          RelativeLayout.LayoutParams adParams =
                  new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                  RelativeLayout.LayoutParams.WRAP_CONTENT);
          adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
          adParams.addRule(RelativeLayout.CENTER_IN_PARENT);
          layout.addView(adView, adParams);
          setContentView(layout);
    
    
    
    
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                         WindowManager.LayoutParams.FLAG_FULLSCREEN);
    glView = new GLSurfaceView(this);
    glView.setRenderer(this);
    //setContentView(glView);
    
    glGraphics = new GLGraphics(glView);
    fileIO = new AndroidFileIO(getAssets());
    audio = new AndroidAudio(this);
    input = new AndroidInput(this, glView, 1, 1);
    PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GLGame");        
    

    }

  2. My Manifest file looks like this ....

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

</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-sdk android:minSdkVersion="7" />

When I first decided to use the XML for admob purpose ..it showed no changes..it even didn't log the device id in Logcat...

Later when I wrote code in the Main Activity class.. and run ... Application crashed ... with 7 errors evry time ...

The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.

The android:configChanges value of the com.google.ads.AdActivity must include uiMode.

The android:configChanges value of the com.google.ads.AdActivity must include screenSize.

The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.

You must have AdActivity declared in AndroidManifest.xml with configChanges.

You must have INTERNET and ACCESS_NETWORK_STATE permissions in AndroidManifest.xml.

Please help me by telling what wrong is there with the code? Can I write code only in xml files without changing the Activity class ... I will be very grateful to anyone providing support.

© Game Development or respective owner

Related posts about android

Related posts about platform-games