<?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>Custom Events &#8211; 記下來</title>
	<atom:link href="https://noter.tw/tag/custom-events/feed/" rel="self" type="application/rss+xml" />
	<link>https://noter.tw</link>
	<description>一路上踩到的坑、遇到的問題，一點一滴記下來，希望能幫助到需要的人~</description>
	<lastBuildDate>Tue, 26 Jul 2022 01:25:04 +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>Custom Events &#8211; 記下來</title>
	<link>https://noter.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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[廣告]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[AdWhirl]]></category>
		<category><![CDATA[kuAD]]></category>
		<category><![CDATA[kuSOGI]]></category>
		<category><![CDATA[Custom Events]]></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 fetchpriority="high" 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>
	</channel>
</rss>
