`
ggyyleo
  • 浏览: 49609 次
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论
阅读更多
Getting Started with AdMob Android Ads
This page will help you get started with becoming a publisher for AdMob Android Ads.

[edit]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
[edit]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
[edit]AdMob Android SDK
The AdMob Android SDK contains the code necessary to install AdMob ads within your application.

[edit]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.




[edit]FAQ
Q: I think I've done everything correctly, but I'm not seeing any ads. What's up with that?

A: You should be seeing a "DidRequestAd" message in your application log. This means that an ad request was made to AdMob, but there was no matching ad to serve in your application. Your integration should be working, and there's nothing else you need to do. If this doesn't work, try the following:

1. Request an ad in test mode.

2. Double-check that your publisher id is set correctly and try again.

3. For the SDK, check whether the included sample projects displays ads. If it does, you might want to check that you are displaying the ad correctly on screen.

4. Confirm that there are ads available for your site by logging in to www.admob.com.

5. Also, the very first request to the AdMob adservers can sometimes take a while; if all else fails, wait 5-10 minutes and try again.

6. If this still doesn't work, email support@admob.com.

Q: Where does the market URL come from?

A: The Android Market URL for your application will be http://market.android.com/search?q=pname: followed by your application's classpath. For example: http://market.android.com/search?q=pname:com.example.ExampleApp

Retrieved from "http://developer.admob.com/wiki/Android"
分享到:
| sadd
评论

相关推荐

    asdsad4654

    asdsad564asd4asd6as54d65as4d

    asdsad22sssdfsdfsdf

    从给定的部分内容来看,这份文档主要介绍了MFC类库参考大全光盘的使用说明,涉及到了光盘内的示例程序、开发环境设置、源代码使用方法、数据库附加过程以及作者提供的技术支持信息。以下是对各个知识点的详细解析: ...

    jjjjjj.zip_Aha!_jjcpp

    描述中的"dsad asdsad cxza casd cxsad as"看起来像是乱码或者故意打乱的字符,可能不是实际的代码内容,而是占位符或者某种加密形式。"Please read your package and"提示我们需要仔细阅读包中的内容,可能意味着...

    spring womat

    【描述】中的 "asdsad spring mvc java 3.0 womat" 提到了Spring MVC、Java和版本号3.0,这暗示了Spring Wombat可能是基于Java语言开发的,并且与Spring MVC 3.0版本兼容。在Spring MVC 3.0中,引入了许多改进和新...

    Vue学习之旅Part14:使用render在Webpack中渲染Vue组件

    步骤1: 在src下创建一个名为后缀名为vue的文件 该文件在Webpack中是纯粹的Vue组件 由三部分组成: ...:业务逻辑 :样式 例: login.vue ...在webpack中若想通过vue将一个组件放到页面中展示 可通过Vue... msg:asdsad },

    MagicDB:Node.jsLevelDB 的一个简单的数据库 API。 就像使用 vanilla JS 对象一样,除了它们会被保存!

    它使用起来非常简单 - 我将坚持使用代码示例。...db.testObj = {'abdscsd':{'asdasds':'asdsad'}}; // This will create a new isolated sublevel for the object - all keys are stored as individual k/v pairs

    proyectoDam:DAM项目4,关于bachaqueros

    DAM项目4,关于bachaqueros asdsad” 描述中提到的是“大坝工程”,这是一个涉及土木工程、环境科学、水资源管理等多个领域的综合性项目。"DAM项目4"可能是一个具体的工程阶段或任务,而“关于bachaqueros”部分...

    变速精灵2.11免费版

    好用到家好用到家好用到家好用到家好用到家好用到家好用到家

    dasdassadas

    asdasdasdasdasdasdasdasd

    阿斯顿撒打算sadsad asdsadsadsa

    爱上大声地sadasdasdasdasda

    c语言入门经典

    c语言经典入门教程之一,内容非常详细且易懂的介绍了c语言的每一个知识点,并且举了很多有用的例子,让读者深刻认识知识点其规律及作用

    EasyHadoop实战手册 大数据时代 ha

    ### EasyHadoop实战手册知识点详解 #### 一、EasyHadoop简介 在当前的大数据时代背景下,处理海量数据的需求日益增长。Hadoop作为一款开源软件框架,被广泛应用于大规模数据处理之中。而EasyHadoop则是在Hadoop...

Global site tag (gtag.js) - Google Analytics