<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AdWhirl &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/adwhirl/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Mon, 13 Mar 2023 14:25:43 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.3</generator>

<image>
	<url>https://noter.tw/wp-content/uploads/cropped-old-1130742_1920-1-32x32.jpg</url>
	<title>AdWhirl &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Google AdWhirl with Vpon</title>
		<link>https://noter.tw/1864/google-adwhirl-with-vpon/</link>
					<comments>https://noter.tw/1864/google-adwhirl-with-vpon/#comments</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Sun, 08 Jan 2012 12:21:03 +0000</pubDate>
				<category><![CDATA[手機 App]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[AdWhirl]]></category>
		<category><![CDATA[Vpon]]></category>
		<category><![CDATA[廣告]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=1864</guid>

					<description><![CDATA[<p>(2012-07-20 更新)前面幾篇小蛙陸續介紹了Google AdWhirl串接kuAD, AdMob，以及單獨使用AdMob(單獨使用Vpon或kuAD只要直接下載匯入範例就可以囉！)，今天要來&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1864/google-adwhirl-with-vpon/" data-wpel-link="internal">Google AdWhirl with Vpon</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>(2012-07-20 更新)前面幾篇小蛙陸續介紹了Google AdWhirl串接kuAD, AdMob，以及單獨使用AdMob(單獨使用Vpon或kuAD只要直接下載匯入範例就可以囉！)，今天要來記錄<span style="color: #ff0000;"><strong>Google AdWhirl with Vpon</strong></span>，算是三者之中最麻煩的。<br />
<span id="more-1864"></span><br />
由於<a href="https://www.vpon.com/" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">Vpon<span class="wpel-icon wpel-image wpel-icon-6"></span></a>會需要用到QRCode讀取套件，因此將Vpon導入Android App中會有比kuAD, AdMob更多步驟，小蛙在導入Vpon的時候發生了很多怪怪的問題，包括了type 17錯誤(已經分不清楚是AdWhirl還是Vpon的錯誤了)，就算直接用Sample Code修改<strong><span style="color: #ff0000;">adOnKey</span></strong>也還是沒辦法顯示(adOnKey在官網上的顯示是「<strong><span style="color: #ff0000;">版位ID</span></strong>」或是英文界面的叫「<span style="color: #ff0000;"><strong>Banner ID</strong></span>」)，小蛙弄到三更半夜還是沒辦法顯示，即使官網上狀態已經顯示「運作中」。今天來記錄一下<strong><span style="color: #ff0000;">Google AdWhirl + Vpon</span></strong>。<br />
Vpon註冊及設定部份由於都是中文也還蠻簡單的，這部份小蛙就跳過，如果在註冊上有遇到任何問題也可以直接留言給小蛙，Google AdWhirl設定也跟串接kuAD的時候差不多，只是Function name把它改成容易辨識的名稱，例如：kuAD小蛙取「<span style="color: #ff0000;"><strong>showKuAD</strong></span>」，就以此類推地把Vpon取名叫做「<strong><span style="color: #ff0000;">showVpon</span></strong>」吧！(<span style="color: #ff0000;"><strong>再次強調這篇使用的是Google AdWhirl</strong></span><span style="color: #000000;">)</span><br />
Vpon AdWhirl比Google AdWhirl多了一個「地區判斷」的功能，因為Vpon是以在地化廣告為宣傳，因此Vpon團隊在AdWhirl中加入了台灣地區及大陸地區的判斷，如果使用者在台灣就會撥放台灣的廣告，反之亦然。由於剛開始串接Vpon的時候遇到了很多奇奇怪怪的問題，因此小蛙使用Google AdWhirl，但新版Vpon AdWhirl應該已經做了修正，如果有兩岸廣告撥放需求的朋友，可以直接使用Vpon AdWhirl來做串接，<strong>官方文件</strong>提供了詳細的說明。<br />
<strong>強烈建議在串接AdWhirl之前，先下載Vpon官方範例程式，修改adOnKey之後跑跑看，如果廣告都沒出現的話，就不用串接了！是不會成功的！</strong><span style="color: #000000;">使用Vpon AdWhirl串接的朋友可以參考以下方法：</span></p>
<ol>
<li>註冊<strong>Vpon帳號</strong>及<strong>Vpon AdWhirl帳號</strong>(這跟Google AdWhirl不同)</li>
<li>在Vpon AdWhirl中新增應用程式(參考<a href="https://noter.tw/1793/adwhirl-with-admob-by-google" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">AdWhirl with AdMob by Google</a>步驟5)</li>
<li>下載最新版的Vpon套件及範例程式。可以在<strong>Vpon + AdWhirl SDK</strong>中找到。</li>
<li>解壓縮後，把專案匯入到Eclipse中(匯入方式請參考<a href="https://noter.tw/1823/eclipse%e5%8c%af%e5%85%a5%e5%b0%88%e6%a1%88" target="_blank" rel="noopener noreferrer" data-wpel-link="internal"><strong>Eclipse匯入專案</strong></a>)。小蛙測試時的版本為「<strong>android-sdk-adwhirl-3.0.3n</strong>」，匯入時選擇「<strong>adOnSample_withAdapters</strong>」資料夾。</li>
<li>將com.android.vpon.addon.AdOnSampleActivity.java中的String <strong><span style="color: #ff0000;">adWhirlKey</span></strong> = &#8220;<span style="color: #809ec2;">ChangeMe</span>&#8220;;修改成步驟2得到的<strong>SDK Key</strong></li>
<li>直接在手機或模擬器上測試就完成了！</li>
</ol>
<p>上面測試沒有問題才繼續以下部份。下面的步驟紀錄串接Google AdWhirl + Vpon。</p>
<ol>
<li>將上面專案中<span style="color: #ff0000;"><strong>res/values</strong></span>下的<strong>attrs.xml, colors.xml, ids.xml, strings.xml</strong>複製到自己專案下，要注意檔案覆蓋問題，保險起見可以開啟這些檔案，例如：開啟strings.xml並複製裡面內容貼到自己的strings.xml。途中有錯誤都先別理它，最後再處理。(2012-07-20 更新)感謝網友ws提醒，要把layout下的<strong>capture.xml</strong>也複製到自己專案下的layout資料夾裡。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/vpon-5.png" data-wpel-link="internal"><img decoding="async" class="alignnone" style="background-image: none; border-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px;" title="vpon-5" src="https://noter.tw/wp-content/uploads/2012/01/vpon-5_thumb.png" alt="vpon-5" width="184" height="203" border="0" /></a></li>
<li>用WinRAR分別開啟Google AdWhirl及Vpon AdWhirl，這個目的是要把Vpon的adapter抓到Google AdWhirl中使用(直接把com\adwhirl\adapters\<span style="color: #ff0000;"><strong>AdOnCNAdapter.class, AdOnTWAdapter.class</strong></span><span style="color: #000000;">拉到Google AdWhirl中</span>)。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/vpon-6.png" data-wpel-link="internal"><img fetchpriority="high" decoding="async" style="background-image: none; border-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="vpon-6" src="https://noter.tw/wp-content/uploads/2012/01/vpon-6_thumb.png" alt="vpon-6" width="544" height="337" border="0" /></a></li>
<li>將必須的JAR加入Java Build Path中(kuAD, GoogleAdMobAdsSdk如果沒使用可以不用理它們)。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/vpon-4.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; margin-right: auto; padding-top: 0px; border: 0px none -moz-use-text-color;" title="vpon-4" src="https://noter.tw/wp-content/uploads/2012/01/vpon-4_thumb.png" alt="vpon-4" width="254" height="476" border="0" /></a></li>
<li>在AndroidManifest.xml中加入以下user permission。
<pre class="brush: xml; gutter: true">&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
&lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
&lt;uses-permission android:name="android.permission.CAMERA"/&gt;
&lt;uses-feature android:name="android.hardware.camera" /&gt;
&lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt;</pre>
</li>
<li>在AndroidManifest.xml中加入以下activity，要放在&lt;application&gt;&lt;/application&gt;之間。
<pre class="brush: xml; gutter: true">&lt;activity android:name="com.vpon.adon.android.WebInApp"
    android:configChanges="orientation|keyboardHidden|navigation|keyboard"
    android:label="@string/app_name"/&gt;
    &lt;activity android:name="com.vpon.adon.android.CrazyAdRun"
        android:configChanges="orientation|keyboardHidden|navigation|keyboard"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent" /&gt;
    &lt;activity android:name="com.vpon.adon.android.webClientHandler.QRActivity"
        android:finishOnTaskLaunch = "true"
        android:clearTaskOnLaunch = "true"
        android:configChanges="keyboardHidden|navigation|keyboard" /&gt;
    &lt;activity android:name="com.vpon.adon.android.webClientHandler.ShootActivity"
        android:finishOnTaskLaunch = "true"
        android:clearTaskOnLaunch = "true"
        android:configChanges="keyboardHidden|navigation|keyboard" /&gt;
    &lt;activity android:name="com.google.zxing.client.android.HelpActivity"
        android:finishOnTaskLaunch = "true"
        android:clearTaskOnLaunch = "true"
        android:configChanges="keyboardHidden|navigation|keyboard" /&gt;
    &lt;activity android:name="com.google.zxing.client.android.CaptureActivity"
        android:finishOnTaskLaunch = "true"
        android:clearTaskOnLaunch = "true"
        android:configChanges="orientation|keyboardHidden"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:windowSoftInputMode="stateAlwaysHidden"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="com.google.zxing.client.android.SCAN"/&gt;
                &lt;category android:name="android.intent.category.DEFAULT"/&gt;
            &lt;/intent-filter&gt;
    &lt;/activity&gt;
    &lt;!-- kuad 的，沒用到kuad的話要拿掉 --&gt;
    &lt;activity android:name="com.kuad.ADDisplay"/&gt;
    &lt;!-- AdMob的 --&gt;
    &lt;activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:name="com.google.ads.AdActivity" /&gt;</pre>
</li>
<li>將上面專案中src下除了com.android.vpon.adon以外的package全部複製下來。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/vpon-1.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; border-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="vpon-1" src="https://noter.tw/wp-content/uploads/2012/01/vpon-1_thumb.png" alt="vpon-1" width="544" height="420" border="0" /></a></li>
<li>在自己專案中的src下貼上。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/vpon-2.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; border-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="vpon-2" src="https://noter.tw/wp-content/uploads/2012/01/vpon-2_thumb.png" alt="vpon-2" width="544" height="321" border="0" /></a></li>
<li>有幾個package及檔案會出現紅色叉叉。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/vpon-3.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; border-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="vpon-3" src="https://noter.tw/wp-content/uploads/2012/01/vpon-3_thumb.png" alt="vpon-3" width="344" height="462" border="0" /></a></li>
<li>開啟有紅色叉叉的檔案，置換.R檔的正確位置(自己主要專案的package)
<pre class="brush: java; gutter: true">//import com.android.vpon.adon.R; //change import
import com.hans.adwhirl.R;</pre>
</li>
<li>確定都沒有紅色叉叉後，加入呼叫AdWirl程式碼。
<pre class="brush: java; gutter: true">package com.hans.adwhirl;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlManager;
import com.adwhirl.AdWhirlTargeting;
import com.adwhirl.AdWhirlLayout.AdWhirlInterface;
import com.adwhirl.AdWhirlLayout.ViewAdRunnable;
import com.adwhirl.util.AdWhirlUtil;
import com.kuad.KuBanner;
import com.kuad.kuADListener;
import com.vpon.adon.android.AdListener;
import com.vpon.adon.android.AdOnPlatform;
import com.vpon.adon.android.AdView;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
public class TestAdWhirlActivity extends Activity implements AdWhirlInterface {
    AdWhirlLayout adWhirlLayout;
    private static final String ADWHIRL_KEY		= "換成自己的Google AdWhirl Key";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // 預留放置廣告的layout
        LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
        // 初始化 adwhirl layout
        adWhirlLayout = new AdWhirlLayout(this, ADWHIRL_KEY);
        AdWhirlManager.setConfigExpireTimeout(1000 * 60);
        // 年齡
        AdWhirlTargeting.setAge(23);
        // 性別
    	AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
    	// 郵遞區號
    	AdWhirlTargeting.setPostalCode("115");
    	// 是否為測試模式，上架時要改成false
    	AdWhirlTargeting.setTestMode(true);
    	// 這行千萬不可以漏掉
    	adWhirlLayout.setAdWhirlInterface(this);
    	// 將 adwhirl layout 放入我們預留的顯示廣告的 layout 中
    	layout.addView(adWhirlLayout);
    }
    @Override
    public void adWhirlGeneric() {
	// TODO Auto-generated method stub
    }
    public void showVpon(){
	AdView adView = new AdView(this);
	adView.setLicenseKey("Vpon Banner ID 輸入在這邊(版面ID)", AdOnPlatform.TW, false);
	adView.setAdListener(new AdListener() {
    	    @Override
            public void onRecevieAd(AdView adView) {
    	        Log.d(AdWhirlUtil.ADWHIRL, "Vpon ad success");
                adWhirlLayout.adWhirlManager.resetRollover();
	        adWhirlLayout.handler.post(new ViewAdRunnable(adWhirlLayout, adView));
	        adWhirlLayout.rotateThreadedDelayed();
	    }
	    @Override
	    public void onFailedToRecevieAd(AdView adView) {
                Log.d(AdWhirlUtil.ADWHIRL, "Vpon ad failure");
	        adView.setAdListener(null);
	        adWhirlLayout.rollover();
	    }
        });
    }
    // for kuAD
    /*
    public void showKuAD(){
        Log.e("showKuAD", "showKuAD()");
	final KuBanner banner = new KuBanner(this);
	banner.setAPID("如果有用kuAD的話，kuAD的APID");
	banner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
	banner.setkuADListener(new kuADListener() {
	    @Override
	    public void onRecevie(String arg0) {
	        Log.e("onRecevie", "onRecevie -&gt; " + arg0);
		adWhirlLayout.adWhirlManager.resetRollover();
		adWhirlLayout.handler.post(new ViewAdRunnable(adWhirlLayout, banner));
		adWhirlLayout.rotateThreadedDelayed();
	    }
	    @Override
	    public void onFailedRecevie(String arg0) {
		Log.e("onFailedRecevie", "showKuAd -&gt; " + arg0);
		banner.setkuADListener(null);
		adWhirlLayout.rollover();
	    }
        });
    }
}</pre>
</li>
<li>可以丟到模擬器或手機上執行囉！</li>
</ol>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1864/google-adwhirl-with-vpon/" data-wpel-link="internal">Google AdWhirl with Vpon</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/1864/google-adwhirl-with-vpon/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>Google AdWhirl with kuAD</title>
		<link>https://noter.tw/1832/google-adwhirl-with-kuad/</link>
					<comments>https://noter.tw/1832/google-adwhirl-with-kuad/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Sat, 07 Jan 2012 08:21:10 +0000</pubDate>
				<category><![CDATA[手機 App]]></category>
		<category><![CDATA[AdWhirl]]></category>
		<category><![CDATA[kuAD]]></category>
		<category><![CDATA[kuSOGI]]></category>
		<category><![CDATA[Custom Events]]></category>
		<category><![CDATA[廣告]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[ads]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=1832</guid>

					<description><![CDATA[<p>(2012-04-06 更新)接續上一篇，小蛙繼續記錄使用Google AdWhirl銜接kuAD，kuAD是由kuSOGI酷手機多媒體公司提供，有很多知名軟體都與kuSOGI合作，例如：休息一夏、A&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1832/google-adwhirl-with-kuad/" data-wpel-link="internal">Google AdWhirl with kuAD</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>(2012-04-06 更新)接續上一篇，小蛙繼續記錄使用Google AdWhirl銜接kuAD，kuAD是由<a href="http://www.kusogi.com/index.php" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">kuSOGI酷手機多媒體公司<span class="wpel-icon wpel-image wpel-icon-6"></span></a>提供，有很多知名軟體都與kuSOGI合作，例如：休息一夏、ATM達人免費版、PlurkQ、台灣特賣會、台灣天氣資訊…等，更多資訊請到<a href="http://www.kusogi.com/p_product/product.php" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">酷手機合作軟體<span class="wpel-icon wpel-image wpel-icon-6"></span></a>查詢。<br />
<span id="more-1832"></span><br />
kuAD申請跟設定的方式跟AdMob其實差不多，不外乎註冊帳號、新增應用程式，輸入一些必要資訊，接著就會讓開發者下載kuAD套件。這裡有一個要注意的部分是如果要再下載一次套件，要連結到<a title="http://app.kusogi.com/sdk.html" href="http://app.kusogi.com/sdk.html" target="_blank" rel="noopener nofollow external noreferrer" data-wpel-link="external" class="wpel-icon-right">http://app.kusogi.com/sdk.html<span class="wpel-icon wpel-image wpel-icon-6"></span></a>下載，或者是要編輯資料之後，才會在出現下載套件的選項(如下圖)。最重要的APID先記錄下來，等一下會使用到。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/kuad-1.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="kuad-1" src="https://noter.tw/wp-content/uploads/2012/01/kuad-1_thumb.png" alt="kuad-1" width="544" height="204" border="0"></a><br />
編輯完資料後才會再出現下載SDK選項(之前小蛙不知道可以到<a title="http://app.kusogi.com/sdk.html" href="http://app.kusogi.com/sdk.html" target="_blank" rel="noopener nofollow external noreferrer" data-wpel-link="external" class="wpel-icon-right">http://app.kusogi.com/sdk.html<span class="wpel-icon wpel-image wpel-icon-6"></span></a>下載)，同時也有<a href="http://kuad.kusogi.com/kuAD/Report/myweb/SDK/Android/kuAD_sdk_Document.pdf" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">kuAD說明文件<span class="wpel-icon wpel-image wpel-icon-6"></span></a>但沒有提到如何串接AdWhirl(也可能有只是小蛙沒找到)。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/kuad-2.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="kuad-2" src="https://noter.tw/wp-content/uploads/2012/01/kuad-2_thumb.png" alt="kuad-2" width="544" height="414" border="0"></a><br />
偷懶很快地跳過kuAD註冊流程 … 要透過AdWhirl串接的話，還需要到Google AdWhirl設定與kuAD的關聯。到AdWhirl中設定Networks，由於Google官方的AdWhirl並沒有內建對kuAD的串接方法，所以這邊我們必須新增一個讓AdWhirl可以知道要做什麼的事件，Add Custom Event –&gt; 名字輸入自己可以辨認得就好，Function Name輸入等一下要從Android程式中呼叫的函式。設定好之後把kuAD Ad Serving打開，% of Traffic設成100%，別忘記最下方的Save Changes。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/kuad-3.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="kuad-3" src="https://noter.tw/wp-content/uploads/2012/01/kuad-3_thumb.png" alt="kuad-3" width="544" height="191" border="0"></a><br />
接下來進行Android程式的部份，將剛剛下載的kuAD_android.zip(如果解壓縮有遇到錯誤，請參考<a href="http://wazai.net/1810/winrar%E8%A7%A3%E5%A3%93%E7%B8%AE%E4%BA%82%E7%A2%BC" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">WinRAR解壓縮亂碼<span class="wpel-icon wpel-image wpel-icon-6"></span></a>)，解壓縮完可以看到kuADSample資料夾, kuAD 1.3.1a.jar, kuAD 1.3.1.jar，kuADSample資料夾可以直接import到Eclipse中(不知道怎麼匯入專案，請參考<a href="http://wazai.net/1823/eclipse%E5%8C%AF%E5%85%A5%E5%B0%88%E6%A1%88" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">Eclipse匯入專案<span class="wpel-icon wpel-image wpel-icon-6"></span></a>)，小蛙在這邊建議要用AdWhirl串接kuAD之前先使用kuADSample看看能不能正常顯示，免得串接之後卻發生一堆讓人摸不著頭緒的問題，而執行kuADSample也很容易，依照Eclipse匯入專案這篇文章操作後就已經完成匯入了，最後一個步驟只需要修改com.sample套件中的kuADSample.java，把<strong><span style="color: #ff0000;">banner.setAPID(&#8220;ZZZZZ0100&#8221;);</span></strong>的ZZZZZ0100改成自己的APID就可以運行了。如果連這個範例都沒辦法顯示出廣告的話，更別提串接AdWhirl，小蛙在這邊卡了很久，如果改了還是沒辦法顯示出廣告，小蛙建議可以直接寫信去問技術人員，也許是哪裡出了問題(Vpon就遇到完全無法顯示，小蛙弄到三更半夜卡了好久還是出不來，問了技術人員才得到「我們技術上出了一些問題，已修正！」的答案…)確定這邊可以呈現出廣告之後，再繼續下面的步驟。<br />
串接AdWhirl來說，小蛙覺得kuAD算是最簡單的了(Vpon最複雜，步驟也多)，首先先將kuAD 1.3.1.jar加入到專案的Java Build Path –&gt; libraries中。在AndroidManifest.xml中加入必要的user permission。<a href="http://kuad.kusogi.com/kuAD/Report/myweb/SDK/Android/kuAD_sdk_Document.pdf" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">官方文件<span class="wpel-icon wpel-image wpel-icon-6"></span></a>。</p>
<pre class="brush: xml; gutter: true">&lt;uses-permission android:name="android.permission.INTERNET"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
&lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;</pre>
<p>在AndroidManifest.xml中新增一個Activity(要放在&lt;application&gt;&lt;/application&gt;之間)。</p>
<pre class="brush: xml; gutter: true">&lt;activity android:name=\"com.kuad.ADDisplay\"/&gt;</pre>
<p>最後程式碼的部份。</p>
<pre class="brush: java; gutter: true">package com.hans.adwhirl;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlManager;
import com.adwhirl.AdWhirlTargeting;
import com.adwhirl.AdWhirlLayout.AdWhirlInterface;
import com.adwhirl.AdWhirlLayout.ViewAdRunnable;
import com.kuad.KuBanner;
import com.kuad.kuADListener;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
public class TestAdWhirlActivity extends Activity implements AdWhirlInterface {
    AdWhirlLayout adWhirlLayout;
    private static final String ADWHIRL_KEY		= "改成自己的AdWhirl Key";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // 預留放置廣告的layout
        LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
        // 初始化 adwhirl layout
        adWhirlLayout = new AdWhirlLayout(this, ADWHIRL_KEY);
        AdWhirlManager.setConfigExpireTimeout(1000 * 60);
        // 年齡
        AdWhirlTargeting.setAge(23);
        // 性別
    	AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
    	// 郵遞區號
    	AdWhirlTargeting.setPostalCode("115");
    	// 是否為測試模式，上架時要改成false
    	AdWhirlTargeting.setTestMode(true);
        // 這行如果漏掉會一直出現type 17的錯誤
    	adWhirlLayout.setAdWhirlInterface(this);
    	// 將 adwhirl layout 放入我們預留的顯示廣告的 layout 中
    	layout.addView(adWhirlLayout);
    }
    @Override
    public void adWhirlGeneric() {
        // TODO Auto-generated method stub
    }
    // 這個方法的名稱必須要跟上面AdWhirl設定的一模一樣
    public void showKuAD(){
        Log.e("showKuAD", "showKuAD()");
	final KuBanner banner = new KuBanner(this);
	banner.setAPID("改成上面申請的kuAD APID");
	banner.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;adWhirlLayout.pushSubView(banner);
	banner.setkuADListener(new kuADListener() {
	    @Override
	    public void onRecevie(String arg0) {
	        Log.e("onRecevie", "onRecevie -&gt; " + arg0);
		adWhirlLayout.adWhirlManager.resetRollover();
		adWhirlLayout.rotateThreadedDelayed();
	    }
	    @Override
	    public void onFailedRecevie(String arg0) {
	        Log.e("onFailedRecevie", "showKuAd -&gt; " + arg0);
		banner.setkuADListener(null);
		adWhirlLayout.rollover();
	    }
	});
    }
}</pre>
<p>快上傳到手機或模擬器上試試看吧！<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/20120107_162022.jpg" target="_blank" rel="noopener noreferrer" data-wpel-link="internal"><img decoding="async" class="alignnone size-full wp-image-1833" title="20120107_162022" src="https://noter.tw/wp-content/uploads/2012/01/20120107_162022.jpg" alt="20120107 162022 Google AdWhirl with kuAD" width="288" height="480"></a><br />
後記：<br />
2012-04-06<br />
小蛙今天在「<span style="color: #ff0000;"><strong>我的股票精算師</strong></span>」中加入選單鍵可以讓使用者選擇要設定投資金額上限、備份、還原或是匯出成交資料&#8230;等等功能，卻發現一個驚人的事實，小蛙的做法是在TabHost上方加上kuAD banner，在某些情況下menu鍵會完整失效，試了一個下午，還以為是哪裡實作有問題，最後發現只要把kuAD banner註解掉，menu鍵就可以完整運作，目前只好先把kuAD banner移到軟體最下方&#8230;之後比較有時間再來想辦法，這裡很詭異的是把kuAD banner移到軟體下方就又可以正常使用，放在軟體上方時好時壞，從DDMS中看到在&#8221;某些情況&#8221;下，menu鍵的主控權會回到TabHost Activity中，而非個別Tab上造成，至於為什麼會有這種情況，今天小蛙還沒有找到答案。<br />
2012-01-23<br />
剛剛發現<a href="http://app.kusogi.com/sdk.html" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">kuSOGI官網<span class="wpel-icon wpel-image wpel-icon-6"></span></a>已經把SDK更新到1.3.5囉！而這一版本已經改掉了執行緒多開的問題！<br />
2012-01-14<br />
kuAD技術人員已經更改了新版的給小蛙測試，的確已經把跨頁會造成執行緒大開的情況修正掉，由於如果軟體一開始設計是以Activity為單位跳頁面，而非像fragment, activitygroup或tabactivity這種可以把廣告固定在每一頁下方，上述程式碼在新版的1.3.4+ kuAD.jar中是可以正常運作的，運作的結果跟Vpon一樣，只會有timed-wait的thread，而不會爆出大量native thread，看來要避掉這個問題只能用上述的三個方法了(activitygroup, tabactivity已經過期了)。<strong><span style="color: #ff0000;">上面的Code為修改過可以使用的，注意必須要搭配1.3.4+ kuAD.jar</span></strong>。今天測試Google AdWhirl當成全域變數嵌入頁面的方法，看起來Thread只會開一次，唯一的缺點只有跳頁的時候會閃爍一下，但廣告不用重新Loading，先memo一下要寫的東西「banner點擊後無法全螢幕顯示」、「繼承Application做法」。<br />
2012-01-09<br />
上面的 code 確定是有問題的，<strong>adWhirlLayout.handler.post(new ViewAdRunnable(adWhirlLayout, banner));</strong> 這行在跨頁面的時候會造成背景開啟一大堆執行緒無法關閉，這個問題就算使用kuad官方的adwhirl也還是存在，小蛙已經回報給kuad技術人員，小蛙也還在等待kuad的回覆。確定可以執行後，小蛙會在這邊繼續記錄後續狀況。<br />
2012-01-08<br />
kuAD後來發現如果使用Google AdWhirl來執行，上面的範例會出錯，造成kuAD廣告快速撥放。<br />
2012-01-07<br />
小蛙的DDMS持續報以下錯誤，後來才發現是漏掉<span style="color: #ff0000;"><strong>adWhirlLayout.setAdWhirlInterface(this);</strong></span>這行造成的。</p>
<pre class="brush: text; gutter: true">01-07 16:24:54.564: D/AdWhirl SDK(2931): Showing ad:
01-07 16:24:54.564: D/AdWhirl SDK(2931): 	nid: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
01-07 16:24:54.564: D/AdWhirl SDK(2931): 	name: event
01-07 16:24:54.564: D/AdWhirl SDK(2931): 	type: 17
01-07 16:24:54.564: D/AdWhirl SDK(2931): 	key: kuAD|;|showKuAD
01-07 16:24:54.564: D/AdWhirl SDK(2931): 	key2:
01-07 16:24:54.574: D/AdWhirl SDK(2931): Valid adapter, calling handle()
01-07 16:24:54.574: D/AdWhirl SDK(2931): Event notification request initiated
01-07 16:24:54.574: W/AdWhirl SDK(2931): Event notification would be sent, but no interface is listening
01-07 16:24:54.574: E/AdWhirl SDK(2931): nextRation is null!</pre>
<p><span style="color: #ff0000;"><br />
</span></p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1832/google-adwhirl-with-kuad/" data-wpel-link="internal">Google AdWhirl with kuAD</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/1832/google-adwhirl-with-kuad/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AdWhirl with AdMob by Google</title>
		<link>https://noter.tw/1793/adwhirl-with-admob-by-google/</link>
					<comments>https://noter.tw/1793/adwhirl-with-admob-by-google/#respond</comments>
		
		<dc:creator><![CDATA[黃小蛙]]></dc:creator>
		<pubDate>Sat, 07 Jan 2012 05:59:22 +0000</pubDate>
				<category><![CDATA[手機 App]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[admob]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[AdWhirl]]></category>
		<category><![CDATA[kuAD]]></category>
		<category><![CDATA[kuSOGI]]></category>
		<category><![CDATA[Vpon]]></category>
		<category><![CDATA[廣告]]></category>
		<guid isPermaLink="false">http://wazai.net/?p=1793</guid>

					<description><![CDATA[<p>AdWhirl是一套廣告輪播平台，開發者如果同時有許多廣告商，例如：AdMob, Vpon, KuAD …等等，就可以透過AdWhirl依照自己的需求來設定百分比輪播廣告，這篇文章小蛙要記錄使用Goo&#46;&#46;&#46;</p>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1793/adwhirl-with-admob-by-google/" data-wpel-link="internal">AdWhirl with AdMob by Google</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>AdWhirl</strong></span>是一套廣告輪播平台，開發者如果同時有許多廣告商，例如：AdMob, Vpon, KuAD …等等，就可以透過AdWhirl依照自己的需求來設定百分比輪播廣告，這篇文章小蛙要記錄<strong>使用Google AdWhirl來播放AdMob廣告</strong>。<br />
<span id="more-1793"></span><br />
可能有些人會覺得如果只用AdMob就依照上一篇文章使用AdMob就好啦！為什麼還要用到AdWhirl，如果只是要放AdMob的確不需要用到AdWhirl，小蛙會用到AdWhirl的原因是想比較各家廣告商在同一期間內可以獲得的收益狀況，還有一個原因是對於台灣地區來說，由於在地化的關係，Vpon及KuAD撥放出來的廣告會比AdMob的廣告更容易吸引使用者。<br />
千萬注意，這邊小蛙用的AdWhirl是<span style="color: #ff0000;"><strong>Google AdWhirl by AdMob</strong></span>(<a title="https://www.adwhirl.com/" href="https://www.adwhirl.com/" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">https://www.adwhirl.com/<span class="wpel-icon wpel-image wpel-icon-6"></span></a>)，由於AdWhirl是Google Project中的Open Source，所以各家廣告商為了吸引開發商或廣告主，都會打著「<strong>整合AdWhirl平台，可以輪播自己想要的廣告</strong>」的名號，像Vpon自己的AdWhirl就增加了「<strong>自動判斷地區</strong>」的服務，由於Vpon服務的客戶有台灣地區及大陸地區，如果能在台灣地區撥放台灣當地的廣告，大陸地區撥放大陸當地的廣告，這樣會使的廣告的投放更有效率(我們會去擊點不相關廣告的機率應該很低吧！比如說在台灣卻去點廣州車商的特惠活動，不小心點到另當別論)；kuSOGI也推出自己的AdWhirl，其中強調的就是可以「同時」(也就是設定比例自動輪播)自家的kuAD以及上面提到的Vpon與AdMob廣告。下面三張圖是三家廣告商的AdWhirl，除了網址列之外，網頁外觀一模一樣，不小心就會搞錯。<br />
<strong>Google AdWhirl</strong><br />
<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-22.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-22" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-22_thumb.png" alt="adwhirl-22" width="544" height="416" border="0"></a><br />
<strong>kuSOGO AdWhirl</strong><br />
<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-21.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-21" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-21_thumb.png" alt="adwhirl-21" width="544" height="416" border="0"></a><br />
<strong>Vpon AdWhirl</strong><br />
<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-20.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-20" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-20_thumb.png" alt="adwhirl-20" width="544" height="416" border="0"></a><br />
如同Android一般，AdWhirl由於是Open Source，意味著各家廠商可以依照自己的需求更改程式碼，也使得各家的AdWhirl可能會有不同的行為模式，Google AdWhirl的使用方法未必會與Vpon AdWhirl或kuSOGI AdWhirl相同，小蛙還是要強調這篇文章記錄的是<span style="color: #ff0000;"><strong>Google AdWhirl</strong></span>，接下來進入正題。</p>
<ul>
<li><span style="color: #ff0000;"><strong>AdWhirl申請及設定</strong></span></li>
</ul>
<ol>
<li>到<a title="https://www.adwhirl.com/" href="https://www.adwhirl.com/" target="_blank" rel="noopener noreferrer nofollow external" data-wpel-link="external" class="wpel-icon-right">https://www.adwhirl.com/<span class="wpel-icon wpel-image wpel-icon-6"></span></a>註冊一個Google AdWhirl帳號。<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-5.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-5" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-5_thumb.png" alt="adwhirl-5" width="544" height="188" border="0"></a></li>
<li>認證完成功登入後進入「Apps」頁籤，點選「Add Application」。<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl_thumb.png" alt="adwhirl" width="545" height="274" border="0"></a></li>
<li>填入應用程式相關資訊，軟體名稱、應用程式URL(market連結)、廣告平台，其他的小蛙都是直接用預設值。(如果要取得地區資訊，把Allow Location Access改成ON)<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-1.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-1" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-1_thumb.png" alt="adwhirl-1" width="544" height="447" border="0"></a></li>
<li>新增完成後就可以在程式列表中看到剛剛新增的應用程式，點選進去。<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-2.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-2" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-2_thumb.png" alt="adwhirl-2" width="544" height="278" border="0"></a></li>
<li>點選AdMob旁邊的「Edit Settings」，將AdMob的發佈商ID填入(<a href="https://noter.tw/1758/google-admob-for-android" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Google AdMob for Android</a>步驟6)。並且將Ad Serving選擇成ON，% of Traffic設定成100%。每次更動都別忘了點選最下方有個「Save Changes」。到這邊AdWhirl就設定完畢了。接下來介紹在Android程式的部份。<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-23.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-23" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-23_thumb.png" alt="adwhirl-23" width="544" height="314" border="0"></a></li>
</ol>
<ul>
<li><strong><span style="color: #ff0000;">在Android程式中加入AdWhirl + AdMob</span></strong></li>
</ul>
<ol>
<li>到「Dev Resources」頁面的「Download the lastest version」下載最新版的AdWhirl套件。<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-25.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-25" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-25_thumb.png" alt="adwhirl-25" width="544" height="312" border="0"></a></li>
<li>下載「AdWhirlSDK_Android_3.1.1.zip」(視當時版本，總之選擇_Android就是了)<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-26.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-26" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-26_thumb.png" alt="adwhirl-26" width="544" height="314" border="0"></a></li>
<li>解壓縮zip檔後得到<span style="color: #ff0000;"><strong>AdWhirlSDK_Android_3.1.1.jar</strong></span>，與<a href="https://noter.tw/1758/google-admob-for-android" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Google AdMob for Android</a>步驟4得到的<strong><span style="color: #ff0000;">GoogleAdMobAdsSdk-4.3.1.jar</span></strong>加入到Eclipse中(加入的方法請參考<a href="https://noter.tw/1758/google-admob-for-android" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Google AdMob for Android</a>步驟10)。加入成功會在Eclispe專案中看到如下圖。<a href="https://noter.tw/wp-content/uploads/2012/01/adwhirl-27.png" data-wpel-link="internal"><img decoding="async" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="adwhirl-27" src="https://noter.tw/wp-content/uploads/2012/01/adwhirl-27_thumb.png" alt="adwhirl-27" width="244" height="241" border="0"></a></li>
<li>先設定需要擺放廣告的layout，小蛙在主layout <span style="color: #ff0000;"><strong>main.xml</strong></span>中新增了一個<span style="color: #ff0000;"><strong>@+id/mainLayout</strong></span>來放置AdWhirl輪播的廣告。
<pre class="brush: xml; gutter: true">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
&nbsp;&nbsp;&nbsp; android:layout_width="fill_parent"
&nbsp;&nbsp;&nbsp; android:layout_height="fill_parent"
&nbsp;&nbsp;&nbsp; android:orientation="vertical" &gt;
    &lt;!-- 用來放置AdWhirl輪播的區塊 --&gt;
&nbsp;&nbsp; &nbsp;&lt;LinearLayout
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;android:id="@+id/mainLayout"
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;android:layout_width="fill_parent"
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;android:layout_height="wrap_content"
&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;android:paddingBottom="10dp"&gt;
&nbsp;&nbsp; &nbsp;&lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;</pre>
</li>
<li>接著在<span style="color: #ff0000;"><strong>AndroidManifest.xm</strong></span>l加入user permission，並且加入一個新的Activity。。
<pre class="brush: xml; gutter: true">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
&nbsp;&nbsp;&nbsp; package="com.hans.adwhirl"
&nbsp;&nbsp;&nbsp; android:versionCode="1"
&nbsp;&nbsp;&nbsp; android:versionName="1.0" &gt;
&nbsp;&nbsp;&nbsp; &lt;uses-sdk android:minSdkVersion="8" /&gt;
&nbsp; &nbsp; &lt;!-- 必要 --&gt;
&nbsp;&nbsp; &nbsp;&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
&nbsp;&nbsp;&nbsp; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
&nbsp;&nbsp;&nbsp; &lt;!-- adwhirl 選用，如果有開啟地區偵測 --&gt;
&nbsp;&nbsp;&nbsp; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
&nbsp;&nbsp; &nbsp;&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
&nbsp;&nbsp; &nbsp;&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
&nbsp;&nbsp;&nbsp; &lt;application
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:icon="@drawable/ic_launcher"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:label="@string/app_name" &gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;activity
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:label="@string/app_name"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name=".TestAdWhirlActivity" &gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;intent-filter &gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;action android:name="android.intent.action.MAIN" /&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/intent-filter&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/activity&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- 一定要新增用來播放廣告的Activity --&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;activity
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; android:name="com.google.ads.AdActivity" /&gt;
&nbsp;&nbsp;&nbsp; &lt;/application&gt;
&lt;/manifest&gt;</pre>
</li>
<li>程式碼的部份。
<pre class="brush: xml; gutter: true">package com.hans.adwhirl;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlManager;
import com.adwhirl.AdWhirlTargeting;
import com.adwhirl.AdWhirlLayout.AdWhirlInterface;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
public class TestAdWhirlActivity extends Activity implements AdWhirlInterface {
&nbsp; &nbsp; AdWhirlLayout adWhirlLayout;
&nbsp; &nbsp; private static final String ADWHIRL_KEY		= "換上自己的adwhirl_key";
&nbsp; &nbsp; @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // 預留放置廣告的layout
        LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
        // 初始化 adwhirl layout
        adWhirlLayout = new AdWhirlLayout(this, ADWHIRL_KEY);
        AdWhirlManager.setConfigExpireTimeout(1000 * 60);
        // 年齡
        AdWhirlTargeting.setAge(23);
        // 性別
    	AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
    	// 郵遞區號
    	AdWhirlTargeting.setPostalCode("115");
    	// 是否為測試模式，上架時要改成false
    	AdWhirlTargeting.setTestMode(true);
    	// 將 adwhirl layout 放入我們預留的顯示廣告的 layout 中
    	layout.addView(adWhirlLayout);
    }
&nbsp; &nbsp; @Override
&nbsp; &nbsp; public void adWhirlGeneric() {
&nbsp; &nbsp; &nbsp; &nbsp; // TODO Auto-generated method stub
&nbsp; &nbsp; }
}</pre>
</li>
<li>這時候會遇到一個錯誤。解決辦法就是把專案的SDK Version設定成3.2+(設定方法請參考<a href="https://noter.tw/1758/google-admob-for-android" target="_blank" rel="noopener noreferrer" data-wpel-link="internal">Google AdMob for Android</a>步驟11)
<pre class="brush: text; gutter: true">Description	Resource	Path	Location	Type
error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').	AndroidManifest.xml	/TestAdWhirl	line 26	Android AAPT Problem</pre>
</li>
<li>如果錯誤還是存在，可以考慮Project –&gt; Clean –&gt; 選擇要清除的專案，執行完畢之後錯誤就消失了！</li>
<li>趕快運行看看，就可以在模擬器或手機上看到Admob廣告囉！<br />
<a href="https://noter.tw/wp-content/uploads/2012/01/20120107_135209.jpg" target="_blank" rel="noopener noreferrer" data-wpel-link="internal"><img decoding="async" class="alignnone size-full wp-image-1797" title="20120107_135209" src="https://noter.tw/wp-content/uploads/2012/01/20120107_135209.jpg" alt="20120107 135209 AdWhirl with AdMob by Google" width="288" height="480"></a></li>
</ol>
<p>這篇文章 <a rel="nofollow" href="https://noter.tw/1793/adwhirl-with-admob-by-google/" data-wpel-link="internal">AdWhirl with AdMob by Google</a> 最早出現於 <a rel="nofollow" href="https://noter.tw" data-wpel-link="internal">記下來</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://noter.tw/1793/adwhirl-with-admob-by-google/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
