구글이 애드몹을 인수를 했었지요?
대략적으로 이번 모바일 개발자 모임등에서도 흘러 나오는 이야기가 애드몹에 대한 내용인것 같습니다.

한번 확인을 해볼 필요가 있지 않을까 생각이 듭니다.
그나 저나 에드센스 계정 블록 당한지 한달이 넘었는대 구글에선 아무런 피드백이 없네요... 속상해 죽을 지경입니다...

애드몹에 대한 위키 좌표입니다.

Getting Started with AdMob Android Ads

This page will help you get started with becoming a publisher for AdMob Android Ads.

Learn about AdMob Android ads

  • AdMob Android ads are a turnkey ad unit for monetizing Android Apps
  • The ad dimensions on the T-Mobile G1 are: 320 pixels wide x 48 pixels tall

Sign up with AdMob

1. Register or login at admob.com, and click 'Sites & Apps".

2. Click "Add Mobile Site", and provide the info for your Android App.

3. Once you've added your site, click "Install Code". You should see a button to download the Android SDK.

4. The download includes the binaries, documentation, and a sample.

  1. Review README.txt
  2. Read documentation/index.html which details how to integrate AdMob ads into your application
  3. Look at the Lunar Lander sample project to see a working example

AdMob Android SDK

The AdMob Android SDK contains the code necessary to install AdMob ads within your application.

SDK Integration Instructions

(1) In your project's root directory create a subdirectory libs. This will already be done for you if you used Android's activitycreator tool. Copy the AdMob Jar file into that libs directory.

For Eclipse projects:

  • Go to the Properties of your project (right-click on your project from the Package Explorer tab and select Properties)
  • Select "Java Build Path" from left panel
  • Select "Libraries" tab from the main window
  • Click on "Add JARs..."
  • Select the JAR copied to the libs directory
  • Click "OK" to add the SDK to your Android project

(2) Add your publisher ID to your AndroidManifest.xml . Just before the closing </application> tag add a line to set your publisher ID. If you publisher ID were, “a149afxxxx”, the line would look like this:

  <meta-data android:value="a149afxxxx" android:name="ADMOB_PUBLISHER_ID" />
  </application>

To find your publisher ID, log into your AdMob account, select the “Sites & Apps” tab, and click on the “Manage Settings” link for your site. On this page, you can find your publisher ID (screenshot below).

(3) Add the INTERNET permission to your AndroidManifest.xml just before the closing </manifest> tag:

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

Optionally, you can add the ACCESS_COARSE_LOCATION and/or ACCESS_FINE_LOCATION permissions to allow AdMob the ability to show geo-targeted ads.

(4) Paste the following into your attrs.xml file:

  <declare-styleable name="com.admob.android.ads.AdView">
     <attr name="backgroundColor" format="color" />
     <attr name="primaryTextColor" format="color" />
     <attr name="secondaryTextColor" format="color" />
     <attr name="keywords" format="string" />
     <attr name="refreshInterval" format="integer" />      
  </declare-styleable>

If your project does not already have an attrs.xml file, then create one in the /res/values/ directory, and paste the following:

  <?xml version="1.0" encoding="utf-8"?>
     <resources>
        <declare-styleable name="com.admob.android.ads.AdView">            
           <attr name="backgroundColor" format="color" />
           <attr name="primaryTextColor" format="color" />
           <attr name="secondaryTextColor" format="color" />
           <attr name="keywords" format="string" />
           <attr name="refreshInterval" format="integer" />
        </declare-styleable>
     </resources>


(5) Create a reference in to the attrs.xml file in your layout element by adding xmlns line that includes your package name specified in AndroidManifest.xml. For example, if your package name were com.example.SampleApp, you would include this line:

  xmlns:myapp="http://schemas.android.com/apk/res/com.example.SampleApp"

So for a simple screen with only one ad, your layout element would look like this:

  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:myapp="http://schemas.android.com/apk/res/com.example.SampleApp"
     android:orientation="vertical"
     android:layout_width="fill_parent"      
     android:layout_height="fill_parent">  
        <com.admob.android.ads.AdView     
           android:id="@+id/ad" 
           android:layout_width="fill_parent" 
           android:layout_height="wrap_content"
           myapp:backgroundColor="#000000"
           myapp:primaryTextColor="#FFFFFF"
           myapp:secondaryTextColor="#CCCCCC"
  />                        
  </LinearLayout>


(6) When integrating AdMob ads into your application it is recommended to use test mode. In test mode test, ads are always returned.

Test mode is enabled on a per-device basis. To enable test mode for a device, first request an ad, then look in LogCat for a line like the following:

  To get test ads on the emulator use AdManager.setTestDevices... 

Once you have the device ID you can enable test mode by calling AdManager.setTestDevices:

  AdManager.setTestDevices( new String[] {                 
     AdManager.TEST_EMULATOR,             // Android emulator
     "E83D20734F72FB3108F104ABC0FFC738",  // My T-Mobile G1 Test Phone
     } );  

}

Once you’ve successfully requested test ads, try clicking on each type of test ad to make sure it works properly from your application. The type of test ad returned is changed with AdManager.setTestAction.

Web Integration

AdMob offers a javascript integration solution for Android and iPhone sites/web apps. The code included below can be found by registering your site as an iPhone Site in your AdMob account. To integrate, simply paste the code below in the exact spot in the page where you want the ad to appear.

<script type="text/javascript">
 var admob_vars = {
  pubid: '[PUBLISHER_ID]', // publisher id
  bgcolor: '000000', // background color (hex)
  text: 'FFFFFF', // font-color (hex)
  test: true // test mode, set to false if non-test mode
 };
 </script>
 <script type="text/javascript" src="http://mm.admob.com/static/iphone/iadmob.js"></script>

The above snippet will always return a test ad for you and during development or testing this should be kept in test mode. Once you set test to false you will receive live ads and affect your impression count. It is possible for you to receive ads in test mode and not see ads once the test mode is false.

Note: If you document has onLoad javascript in the BODY tag, ads may not always appear. See next section.

Additional API/Technical Notes

This section is for web apps or publishers that are experienced in javascript

Our javascript is written in such a way to be the lowest possible integration bar for general users. This means that the above code simply fires off an initialize function on the window 'load' event (akin to <body onload='_admob.init()'>). The init event looks for our script tags in the dom and works off these hooks. This means inserting the script dynamically into your page will fail.

If you are in need to insert ads dynamically into your page use the following method:

<script type="text/javascript">
 var admob_vars = {
  pubid: '[PUBLISHER_ID]', // publisher id
  test: true, // test mode, set to false if non-test mode
  manual_mode: true
 };
 </script>
 <script type="text/javascript" src="http://mm.admob.com/static/iphone/iadmob.js"></script>

This will suppress the init function. To request an ad use the following function

/**
 * @param el Node a dom element
 * @return object adEl is a handle to the ad.
 */
 _admob.fetchAd = function(el) {
  ....
   return {
     adEl: adFrame   
   };
 };

for example if you want an ad rendered in a <div id='admob_ad'></div> use:

 _admob.fetchAd(document.getElementById('admob_ad'));

Please keep in mind that id's must be unique to the page.

You can also use this handle to hide ads.

 var ad = _admob.fetchAd(document.getElementById('admob_ad'));
 ad.adEl.style.display = 'none'; // OR hide it w/o affecting dom layout
 ad.adEl.style.visibility = 'hidden';

You can programmatically display a new ad by putting an ad web page in an IFRAME:

 <script>
       ...
       <iframe id="admob_ad" style="position: absolute; width: 320px; height: 48px; left: 0px; top: 0px;" noresize="noresize" frameborder="0" src="http://your_site.com/your_admob_web_page.html">
       </iframe>
       ...
 </script>
 <script>
       ...
       // refresh the IFRAME where you want to display a new ad
       var adIframeEl = document.getElementById("admob_ad");
       
       adIframeEl.src = adIframeEl.src;
       ...
 </script>

_admob.fetchAd returns the following object

  {
   adEl: <handle to the ad frame, this is an iframe>
   shim: <handle to the shim under the ad frame, this is a div>
 }

If you want to detect that an ad has returned you can check the height of the iframe.

 <script>
 var ad = _admob.fetchAd(document.getElementById('admob_ad'));
 var polling_timeout = 0;
 var polling_func = function() {
  if(ad.adEl.height == 48) {
    // we have an ad
    console.log('received ad');
  }
  if(polling_timeout < 5000) {
    console.log('repoll');
    polling_timeout += 1000;
    window.setTimeout(1000, polling_func);
  }
  else {
    console.log('no ad');
    // 5 seconds reached, slow network, or no ad was returned
  }
 };
 window.setTimeout(polling_func, 1000);</script>

Also, clicks can be opened in a new tab in Web Apps. *note: this will only work for ads that link to web pages. Simply use:

<script type="text/javascript">
 var admob_vars = {
  ...
  new_window: true
 };
 </script>

+ Recent posts