Sunday, June 27, 2010

How to add Google Adsense Ads to your Android App

After I got a taste of how is to build apps for Android on mobile, I wanted to go further and insert ads into my apps. Other apps that I previously downloaded had that and it wasn't that annoying seeing ads at the bottom of my screen and I felt good that free apps can get people's support through Adsense mechanism.

I read a little bit on the Google's Adsense Setup page that you can "Unlock the revenue potential of your mobile site with targeted Google ads." This sounded so good that I wanted to try.
But wait, Google is talking about my mobile sites where I can put Google ads, while I'm trying to add these ads to my android apps. How can I do that ? You'll see that is not that complicated and in fact is very simple .

And here is how I succeeded adding Google Adsense Ads to my android apps: "World Cup Goal Scream" and "World Cup Red Vuvuzela". You can download these apps from android market to get a feeling of what I'm talking about.

The following is a step by step guide for you and for me. Yes for me too, because we always forget stuff and thank God to the internet that we have a place to come back and save the day.

Ok, let's go

Step 1:
Create a Google account, if you don't have one, and log in to the Google Adsense site (

Step 2:
Select "Adsense Setup" from the menu

Step 3:
Select "AdSense for Mobile Content New high-end devices!" and follow the wizard steps to customize you ads.

Step 4:
Get "Your AdSense code" and save it to an empty html page

<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="">
<title>World Cup Goal Scream Ads</title>
<body marginwidth="0" marginheight="0 leftmargin="0"
topmargin="0" style="background-color: black">
.....insert your Adsense Code here.........

And save the page, for example call it myads.html

Step 5:
Upload this page to your website, oh you need a place on the internet where you can upload stuff

Step 6:
Test the page on your mobile phone by opening the page that you just upload.
Note!: it won't display any content if you open the page from your computer's web browser. You have to test it on your mobile web browser. Check out my ads page:

Step 7:
Now that you have this page, you probably ask yourself "How the hack do I add it to my app ?"
Well don't worry you are on track to do this.
Take a deep breath of fresh air and proceed with the next step.

Step 8:
Open your Android project and edit the View where you want to add your ads.
For example you can add ads to your main.xml where you'll place a WebView component.

<LinearLayout android:id="@+id/adsHolder"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_alignParentBottom="true"
android:layout_centerInParent="true" android:paddingTop="5px">
<WebView android:id="@+id/adsDisplay" android:layout_width="fill_parent"
android:layout_height="fill_parent" />

Step 9:
All you have to do now is to wire up the WebView component that you just add to your web page created in Step 4

public class MainActivity extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
WebView adsDisplay = (WebView) findViewById(;

Step 10:
Add user INTERNET permission to your app by editing the AndroidManifest.xml file

<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />

Step 11:
You're done, test it by building your app and run it with your emulator or on your mobile phone and you should see your ads at the bottom of your screen.

A quick overview of the steps
Step 1 : Log in to the Google Adsense site
Step 2-3 : Get Your Adsense Code
Step 4 : Save it to an empty web page (example:
Step 5 : Upload the page to your website
Step 6 : Test it on your mobile
Step 7 : Fresh air
Step 8 : Add a WebView component to a view in your android project
Step 9 : Wire up the component to display you web page that you just created in Step 4
Step 10 : Add INTERNET permission to your app
Step 11 : FINISH (check your heart rate :) )

That's pretty much it.

I hope that you find this posting useful and don't stop building free apps and get support for your development using Google Adsense for mobile.

If you find this blog entry useful don't stop sharing with your friends and CLICK MY ADS to support my development and I'll get you more tutorials


  1. Not a good idea.

    You are not actually allowed to use AdSense ads in Android apps (there is an SDK on the way to allow this to be done legally), and people who have done as you suggest previously have had their Adsense accounts suspended.

    I would recommend people to either wait for Google to release the official Adsense SDK for Android or sign up with Admob (which has been bought by Google) or Mobclix.

    1. Admob won't work if you want keep your app Android 1.6 compatible. This tutorial shows how to keep it.

    2. Machine Learning Projects for Final Year machine learning projects for final year

      Deep Learning Projects assist final year students with improving your applied Deep Learning skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include Deep Learning projects for final year into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Deep Learning Projects for Final Year even arrange a more significant compensation.

      Python Training in Chennai Project Centers in Chennai

  2. It depends on how you do your mobile ads. If you've been accepted to Google's beta program, by all means go for it - the fill rate is way better. But if you're just making a little window just for your adsense ads, you'll probably get banned for it, like Michael said.

    From the google website, they say that their crawler needs to be able to crawl the website your ads are coming from, and that those ads need to be nested in either WML, XHTML, HTML, or CHTML; with restrictions even on those. (ref

    Although I think this idea is genius, apparently Google doesn't yet. I guess we just have to be patient and wait for the official Adsense SDK.

  3. Its very nice post and very helpful for me in fact...

    Thanks for writing this type of posts


  4. Thanks man, it's very usefull "tutorial" for beginers like me ;)

  5. Got plagiarized...

  6. Thanks For Your valuable posting, it was very informative. Am working in Erp Software Company In India

  7. Thanks dear.. very helpful .

  8. your blogs is awesome.
    Caller Tune
    With Videocon Caller Tunes, you can play your favorite song for all your callers instead of the boring Tring Tring! Choose from Bollywood to International hits, wacky sounds to pure instrumental and MORE. To activate Call 543211 @Rs3/min or SMS CT ACT to 121 (Toll Free) or dial *501# (toll free browsing). Rs. 15 per Tone Download. To deactivate the service SMS CT DCT to 543211 (Toll Free).

  9. Hello,
    It's a cracking article really. Concisely written and full of useful advice and links. I’ll definitely be bookmarking and sharing. Thanks you for sharing.

  10. Hello,
    It's a cracking article really. Concisely written and full of useful advice and links. I’ll definitely be bookmarking and sharing. Thanks you for sharing.

  11. your blogs is awesome.
    4G internet Service
    Videocon Telecom to rollout 4G services in UPE, UPW & Bihar Telecom circles. Plans to utilize the entire spectrum for 4G LTE FDD rollout on 1800 Mhz band in select cities & offer voice on overlay Network.

  12. Wir schaffen mobile Anwendungen auf Nachfrage ! eines der besten Unternehmen die Entwicklung mobiler Anwendungen in Deutschland , die Anwendungen machen Android , Windows und iOS gestartet.

  13. hope that this feature will offer you engaging conversations and exchanges on a variety of topics.

  14. If you're looking for a solid contextual advertising network, I suggest you check out Clicksor.

  15. No matter if some one searches for his vital thing, thus he/she desires to be available that in detail, thus that thing is maintained over here.

    Urenregistratie zzp

  16. What's up, for Search engine streamlining genuine substance are truly required, in case you simply make a copy and paste then you can not situated in web records.Lol Rank Boost

  17. Why visitors still make use of to examine news papers when in this creative world everything is accessible on net?Elo Boosting

  18. Howdy! This is my first visit to your site! We are a gathering of volunteers and starting another action in a gathering in the same corner. Your site gave us profitable information to tackle. You have made an uncommon appearing with respect to!Email Hosting Services Singapore

  19. all the time i used to peruse littler articles that likewise clear their intention, and that is additionally happening with this bit of composing which I am perusing here.

    Fixing tabletipad repair

  20. is there a cost in Google Ads for impression(CPM)?

    Wedding Photographers in Chennai

  21. Cost Per Click vs Cost Per Impression - Which One Is Better?

    Inplant Training in Chennai

  22. thanks a lot for sharing! you can learn more about mobile app development Singapore if you're interested :)

  23. Considering to join additional affiliate networks?
    Visit this affiliate directory to see the ultimate list of affiliate networks.

  24. Sell your iTunes Gift cards for Up To 70% Value in U.S.A, canada, UK, Nigeria. sell gift cards for cash instantly
    sell itunes gift card

  25. I gotta favorite this website it seems very helpful .

  26. Quality content is the key to invite the users to go to see the site, that’s what this website is providing.

    Best SEO Company In Kanpur india

  27. Hey, Wow Provided Post will be Very much Informative to the People Who Visit this Site. Good Work! Thank You for Sharing.
    manufacturing erp software in chennai

  28. I really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day! 


  29. Nice! you are sharing such helpful and easy to understandable blog in decoration. i have no words for say i just say thanks because it is helpful for me.

    robotic process automation companies in us
    Robotic Process Automation in us
    machine maintanance in us
    erp in chennai
    mobility software companies in chennai
    erp providers in us

  30. i am browsing this website dailly , and get nice facts from here all the time .