I tried to integrate ads into my Android app, and now I have achieved this. Following are the steps.
1.You must have a gmail account.
2.Open www.admob.com
3. "Sign Ino Admob" will be there.
4.Select your gmail username and password.
5. After logging in, you will be asked to fill out some forms.
6. After filling, you will be taken to a new page where the option "Monetization" will appear.
7.Under Monetize you click "Monetize a new application."
8. Select "Add application manually."
9. Enter the name of the application and select "Platform".
10. Now go to the section "Selecting the ad format and ad unit with the name".
11. Select "Banner".
12. Enter the name of the ad unit.
13. Click Save.
14. You will receive an “Ad Unit ID,” which usually starts with ca. You must write it down for future use in the application.
These are the steps that you will follow as a first step. Now the next steps, you have to execute it in android code. I am using eclipse.
1. Eclipse of the eclipse.
2.Create a new Android application project.
3.Download GoogleAdMobAdsSdk-4.1.1.jar
4. Include this jar in the libs of your project.
5. Now right-click on the project, go to the "Properties", "Enter", "Java Build", "Go", "Libraries", "Add Banks", "Add Banks" section. Select the jar that was recently added to libs.Click ok and exit.
6. Now open the AndroidManifest.xml of your project. Include the following two file permissions above the application tag.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7. Inside, you should declare AdActivity as follows
<application> . . . <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> . . . </application>
8.Open the xml layout activity_main and paste the following code.
<com.google.ads.AdView xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" googleads:adSize="BANNER" googleads:adUnitId="Your Add unit id" />
Note the value for googleads: adUnitId will be the identifier you created with admob.com. I asked you to mark it before. Hope you remember.
9.Open MainActivity, paste the following code in oncreate
AdView mAdView; oncreate() { mAdView = (AdView) findViewById(R.id.ad); mAdView.setAdListener(new MyAdListener()); AdRequest adRequest = new AdRequest(); adRequest.addKeyword("sporting goods"); mAdView.loadAd(adRequest); }
10. Add the following code to MainActivity as an inner class
private class MyAdListener implements AdListener { @Override public void onFailedToReceiveAd(Ad ad, ErrorCode errorCode) { } @Override public void onReceiveAd(Ad ad) { } @Override public void onDismissScreen(Ad arg0) {
It is finished. Try the above and let me know the reviews.
thanks
Linsi