To build a better world !

          開始Admob廣告盈利模式詳細教程


                  花了整整一天時間,研究怎么通過在Android應用程序中添加Admob廣告來賺錢。網上也有些教程,不過說得不夠詳細,自己還得花時間摸索。為了讓后來者能更快開始Admob廣告賺錢,所以寫個詳細一點的教程,供大家參考。

                  例子工程源碼下載地址:     下載源代碼
                 
                  當然,我也參考了一些網上的資料,主要有:

                  AdMob:在android應用中嵌入廣告的方案
                  如何在Android Market賺錢 part 2 - 免費app附帶廣告
                  Publisher Starter Kit
                  面向開發者 Wiki 的 AdMob

                  好了,現在讓我從頭開始說起……在這之前,你不需要有任何的帳號,唯一需要的就是有一個有效的email郵箱。只要按照下面的步驟一步步來,你就能通過將Admob的廣告插到自己的程序中賺錢啦!

                  首先,當然是需要注冊一個Admob的帳號。Admob的主頁是:http://www.admob.com/ 。 當然,如果你對于瀏覽英文網頁還有些障礙的話,可以登錄中文網站:http://zhcn.admob.com/ 。如果網站的文字還是英文,你可以在網站主頁的右下角的“Language”處,選擇“中文(簡體)”。點擊進入注冊頁面后,有一些欄目需要填寫,不要太過疑慮,就像你注冊一個論壇一樣,隨便填下就好了。最關鍵的是保證填寫的email地址有效,另外就是填上姓名,選擇語言。帳戶類型我選擇的“不確定”,語言“中文(簡體)”~ 提交注冊申請之后,不久你就會收到用于確認并激活帳號的電子郵件,點擊激活鏈接,就可以了激活你的Admob帳號了~

                  第二步就是設置你的Android應用程序信息,并獲得Admob的插入代碼登錄你的Admob帳號后,在主頁的左上方(Logo上面)點擊“Marketplace(手機廣告市場)”,進入頁面后,在“Sites&Apps(站點和應用程序)”標簽下,點擊“Add Site/App”。選擇我們熟悉的圖標——" Android App ” 。這時會出現需要你填寫一個“詳細信息”,隨便填上一些信息。(不要太過在意現在填寫的東西,因為這些以后都是可以修改的)。比如“Android Package URL” 我到現在都還沒有填寫,描述之類的,想寫就寫點吧。填好詳細信息后,點擊“繼續”,就可以到AdMob Android SDK 的下載頁面了。下載這個SDK(當然,這個很重要)。

                  The AdMob Android SDK includes:

                  README: Get started with AdMob Android ads! 
                  AdMob Jar file: Required for publishing ads. Follow the documentation in javadoc/index.html and drop the AdMob Jar file into your project. 
                  Sample Projects: Examples of AdMob Android ads shown in the LunarLander application.

                  第三步獲取你的應用程序對應的Publisher ID。在下載頁面點擊"Go to Sites/Apps"就可以到你應用程序的管理界面了。這時你會發現在這個頁面醒目的位置會有一個叫你填寫詳細信息的提示:

                    在我們發送任何有待收入之前,您需要填寫技術聯系詳細信息和付款首選項

                  我們暫時可以不用管它,因為錢是會存在我們的Admob的賬戶上的,等我們需要提現的時候,或者你想填的時候再填就可以了。在下面的列表中,選擇你的應用程序并進入。這個界面就是你的應用程序廣告的管理界面了,里面有比較多的功能,以后可以慢慢了解,現在我們只需要知道兩個東西,一個是發布者 ID(Publisher ID),一個是你程序的狀態。Publisher ID是一個15個字符的字符串,而你程序的狀態現在應該還是不活動(Inactive)。我們下面要做的就是怎么讓它變為Active。

          第四步代碼編寫——在你的應用程序中插入Admob廣告。經過上面的步驟,我們在網站上的設置就告一個段落了,現在我們終于要進入主題了,如何在自己的Android應用程序中插入Admob廣告。如果你不健忘的話,一定還記得我們之前下載的那個AdMob Android SDK 。解壓它,看看里面有些什么東西。這里面最重要的就是那個名為“admob-sdk-android.jar”的包啦,Admob將如何把廣告加載到Android應用程序中的代碼集成在這個包里,我們編寫程序的時候就需要將這個包導入到我們的工程里面去。另外,解壓出來的文件夾中還有一個名為“javadoc”的文件夾,打開它里面的index.html。它是關于Admob Android SDK的幫助文檔,在Package 下的Setup下,有詳細完整的在自己的應用程序中插入廣告的方法介紹,在這里我就偷懶,引用一下~

                  Including the Jar

                  Add the Jar file included with the SDK to your Android project as an external library. In your project's root directory create a subdirectory libs (this will already be done for you if you used Android's activitycreator). Copy the AdMob Jar file into that 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

                  注意:需要首先在你工程的根目錄下新建一個叫做“libs”的文件夾,并把之前所說的最重要的東西“admob-sdk-android.jar”復制到里面。


                  AndroidManifest.xml

                  Your AdMob publisher ID was given to you when creating your publisher account on www.admob.com before downloading this code. It is a 15-character code like a1496ced2842262. Just before the closing </application> tag add a line to set your publisher ID: 

                          <!-- The application's publisher ID assigned by AdMob -->
                          <meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" />
                  </application>

                  Set any permissions not already included just before the closing </manifest> tag: 

                          <!-- AdMob SDK permissions -->
                          <uses-permission android:name="android.permission.INTERNET" />
                          <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
                  </manifest>

                  Only the INTERNET permission is required. Setting ACCESS_COARSE_LOCATION (and/or ACCESS_FINE_LOCATION) allows narrowly geo-targeted ads be shown.

          這里需要注意的是,<meta-data android:value="YOUR_ID_HERE" android:name="ADMOB_PUBLISHER_ID" />中,我們只需要改的是"YOUR_ID_HERE"。這里需要你填上的ID就是我們之前在Admob網站我們的應用程序管理頁面上看到的Publisher ID,而name="ADMOB_PUBLISHER_ID"是不應該改的。程序需要這個Key來查找對應的Value。


                  attrs.xml

                  The attrs.xml file specifies custom AdView attributes in XML layout files. If your application does not already have an /res/values/attrs.xml file then create one and copy-and-paste the following into it. If you do have that file then just add the declare-styleable element:


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

                  這個,沒什么說的。


                  Placing an AdView in a Layout

                  AdView widgets can be put into any XML layout now. The first step is to reference attrs.xml in your layout element by adding an xmlns line that includes your package name specified in AndroidManifest.xml: 

                  xmlns:yourapp=http://schemas.android.com/apk/res/yourpackage

                  For example a simple screen with only an ad on it would look like: 

                  <?xml version="1.0" encoding="utf-8"?>
                  <LinearLayout
                          xmlns:android="http://schemas.android.com/apk/res/android"
                          xmlns:admobsdk="http://schemas.android.com/apk/res/com.admob.android.example"
                          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"
                                  admobsdk:backgroundColor="#000000"
                                  admobsdk:textColor="#FFFFFF"
                                  admobsdk:keywords="Android application"
                          />
                                 
                  </LinearLayout>

                  這里好像也沒什么需要特別注意的,注意加上xmlns,另外知道這里可以設置一個keywords。


                  Test Mode

                  When you start integrating AdMob ads into your application it is recommended to use test mode. This always returns the same ad. Normal ad requests are not deterministic making it harder to be sure the ad view looks like you want (e.g. ad requests can timeout or may not fill). 

                  
          Once the ad shows up as you expect be sure to turn test mode off to get real ads. Never put your application into the Android Market with test mode enabled.

                   Test mode can be enabled either by calling AdManager.setInTestMode(true) or by adding a "admobsdk:testing="true"" property to the ad in your XML layout (where "admobsdk" is the XML namespace for your application).


                  設置Test Mode這個很關鍵,千萬別將處于Test Mode的程序發布出去了,那樣可賺不了錢啊~!如果在AdView的屬性中不加上admobsdk:testing="false",似乎程序也是不處于Test Mode的,不過最好還是加上吧~

                  第五步編譯運行,并激活程序。編譯運行你的程序,在模擬器上就可以看到效果啦~(當然你的模擬器需要能上網,關于怎么讓模擬器上網呢?用路由的應該可以直接上,如果不是用路由,那么可能需要設置下,具體方法大家自己網上搜吧,具體忘了)。如果你的應用程序能顯示出廣告,那么恭喜你,你的應用程序很快就會在Admob上被激活了(需要一定的時間,我的好像花了一個小時不到)!

                  第六步在Admob網站上查看應用程序賺了多少錢~“手機廣告市場”—>“報告”—>“站點和應用程序報告”。選擇你的應用程序,然后點擊頁面最下面的“創建報告”~ OK,賺錢啦~

          最后,我把我自己寫的一個例子工程上傳上來,大家可以下載來參考下。另外,我的工程將廣告作為移動的,并且改變了它默認的寬度和背景,希望對如何在應用程序中擺放廣告,起到一個拋磚引玉的作用。效果圖如下(哈哈,在模擬器跑的~):



              例子工程源碼下載地址:     下載源代碼


                

          posted on 2010-01-03 22:17 zh.weir 閱讀(8055) 評論(2)  編輯  收藏 所屬分類: Android盈利模式

          評論

          # re: 開始Admob廣告盈利模式詳細教程[未登錄] 2010-06-10 23:14 jack

          寫的好啊,謝謝了。
          我已經在我的網站上轉載您的文章。
          http://www.getideas.cn/  回復  更多評論   

          # re: 開始Admob廣告盈利模式詳細教程[未登錄] 2010-06-28 04:48 liu

          好用
            回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          公告

          大家好!歡迎光臨我的 Android 技術博客!



          本博客旨在交流與 Android 操作系統相關的各種技術及信息。

          博客內的文章會盡量以開源的形式提供給大家,希望我們能相互交流,共同提高!

          有不足之處,請不吝賜教!

          我的郵箱:zh.weir@gmail.com
          我的新浪微博:@囧虎張建偉

           

          導航

          <2010年1月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統計

          留言簿(19)

          隨筆分類(24)

          隨筆檔案(18)

          文章檔案(1)

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 嘉善县| 安陆市| 乌拉特中旗| 沐川县| 上犹县| 南靖县| 榆树市| 古田县| 遵义市| 海盐县| 凭祥市| 柘城县| 通渭县| 五家渠市| 玉溪市| 锡林浩特市| 临沭县| 公安县| 宁乡县| 绥江县| 郧西县| 淮滨县| 南漳县| 肇东市| 香港| 武强县| 霍州市| 西林县| 建阳市| 库尔勒市| 宜宾市| 汾阳市| 金昌市| 青河县| 饶阳县| 应城市| 兴山县| 宁夏| 剑阁县| 阿拉善左旗| 新和县|