|
|
| (24 intermediate revisions by 3 users not shown) |
| Line 3: |
Line 3: |
| | 以下將說明您怎麼整入 AdLocus SDK. | | 以下將說明您怎麼整入 AdLocus SDK. |
| | | | |
| | + | 自我檢查 |
| | + | === Android Studio === |
| | + | * Gradle 中加入AdLocus (Y/N) |
| | + | * Tool > Android > Sync Project With Gradle Files (Y/N) |
| | + | |
| | + | 若您已完成上述檢查卻無法正確啟用相關服務, 請來信 support@adlocus.com , 我們將有專人與您聯繫. |
| | | | |
| | == 取得您的 App Key == | | == 取得您的 App Key == |
| − | ** 至 http://adlocus.com/ 申請帳號並登入。
| + | * 至 https://adlocus.com/ 點 <開發商> 申請帳號並登入。 |
| − | ** 在「應用程式」中「新增」您的應用程式並取得app key。
| + | * 在「應用程式」中「新增」您的應用程式並取得app key。 |
| | | | |
| | == 準備將 SDK 加入到您的專案 == | | == 準備將 SDK 加入到您的專案 == |
| − | * AdLocus JAR 檔 | + | * [[Android_AddSDK|加入SDK]] |
| − | ** 在專案底下建立 libs 資料夾 ( 在專案上按右鍵 > New > Folder,在 Folder name 填入 libs ,點選 Finish)
| + | |
| − | ** 將 adlocus_<version>.jar 複製到 libs 資料夾底下
| + | |
| − | | + | |
| − | * AdLocus Library Project
| + | |
| − | ** 第一步: 加入 AdLocus Library Project 到您的 Eclipse Workspace 中
| + | |
| − | [[File:LibProj_1.jpg]] | + | |
| − | [[File:LibProj_2.jpg]]
| + | |
| − | [[File:LibProj_3.jpg]]
| + | |
| − | | + | |
| − | ** 第二步: 在您的專案內啟用 AdLocus Library Project
| + | |
| − | [[File:LibProj_p1.jpg]]
| + | |
| − | [[File:LibProj_p2.jpg]]
| + | |
| − | [[File:LibProj_p3.jpg]]
| + | |
| − | [[File:LibProj_p4.jpg]]
| + | |
| − | | + | |
| − | * AndroidManifest.xml 中加入以下權限
| + | |
| − | <syntaxhighlight lang="java">
| + | |
| − | // InApp
| + | |
| − | <uses-permission android:name="android.permission.INTERNET" />
| + | |
| − | <uses-permission android:name="android.permission.READ_PHONE_STATE" />
| + | |
| − | <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
| + | |
| − | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
| + | |
| − | <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
| + | |
| − | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
| + | |
| − | | + | |
| − | // Promotion
| + | |
| − | <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
| + | |
| − | <uses-permission android:name="android.permission.WAKE_LOCK" />
| + | |
| − | <uses-permission android:name="com.adlocus.permission.SEND" />
| + | |
| − | <permission android:name = "com.adlocus.permission.SEND" />
| + | |
| − | | + | |
| − | <service android:name="com.adlocus.push.PushService"
| + | |
| − | android:process=":adlocus">
| + | |
| − | </service>
| + | |
| − | | + | |
| − | <receiver
| + | |
| − | android:enabled="true"
| + | |
| − | android:process=":adlocus"
| + | |
| − | android:name="com.adlocus.push.PushReceive"
| + | |
| − | android:permission="com.adlocus.permission.SEND">
| + | |
| − | <intent-filter>
| + | |
| − | <action android:name="android.intent.action.BOOT_COMPLETED" />
| + | |
| − | <category android:name="android.intent.category.DEFAULT" />
| + | |
| − | </intent-filter>
| + | |
| − | <intent-filter>
| + | |
| − | <action android:name="com.adlocus.action.RECEIVE" />
| + | |
| − | </intent-filter>
| + | |
| − | </receiver>
| + | |
| − | | + | |
| − | </syntaxhighlight>
| + | |
| − | | + | |
| − | 就這麼簡單,您已完成SDK的前期作業。
| + | |
| − | | + | |
| | | | |
| | == InApp == | | == InApp == |
| − | 在 Activity 中加入以下程式碼
| + | * [[Android_InApp|詳細說明]] |
| − | <syntaxhighlight lang="java">
| + | |
| − | import com.adlocus.*;
| + | |
| − | | + | |
| − | usLayout adlocusLayout =
| + | |
| − | new AdLocusLayout(this,
| + | |
| − | AdLocusLayout.AD_SIZE_BANNER, //設定廣告大小,通常為 Banner
| + | |
| − | your app key, //填入 app key
| + | |
| − | 15); //設定輪播時間,最低 15 秒,-1 為不輪播只顯示一則
| + | |
| − | | + | |
| − | // 設定輪播動畫,預設為淡入,範例設定為隨機動畫
| + | |
| − | adlocusLayout.setTransitionAnimation(AdLocusLayout.ANIMATION_RANDOM);
| + | |
| − | LinearLayout.LayoutParams adlocusLayoutParams = new LinearLayout.LayoutParams(
| + | |
| − | ViewGroup.LayoutParams.WRAP_CONTENT,
| + | |
| − | ViewGroup.LayoutParams.WRAP_CONTENT);
| + | |
| − | // 設定置中
| + | |
| − | adlocusLayoutParams.gravity = Gravity.CENTER;
| + | |
| − | // 加入到你的 layout 中
| + | |
| − | yourLayout.addView(adlocusLayout, adlocusLayoutParams);
| + | |
| − | yourLayout.setGravity(Gravity.CENTER_HORIZONTAL);
| + | |
| − | yourLayout.invalidate();
| + | |
| − | </syntaxhighlight>
| + | |
| − | | + | |
| − | AD SIZE 說明:
| + | |
| − | AdSize Constant Size (WxH) Availability
| + | |
| − | # AD_SIZE_BANNER 320x50 (dp) 手機及平板
| + | |
| − | # AD_SIZE_IAB_MRECT 300x250 (dp) 平板
| + | |
| − | # AD_SIZE_IAB_LEADERBOARD 728x90 (dp) 平板
| + | |
| − | | + | |
| − | 注意 : 請確保 layout 的空間大於等於您所設定的 AD size,否則將不會展示廣告。
| + | |
| − | | + | |
| − | === 若您需要監聽廣告互動結果 ===
| + | |
| − | 加入以下程式碼即可監聽相關事件
| + | |
| − | <syntaxhighlight lang="java">
| + | |
| − | adlocusLayout.setListener(new AdListener()
| + | |
| − | {
| + | |
| − | @Override
| + | |
| − | public void onReceiveAd(Ad adView)
| + | |
| − | {
| + | |
| − | AdLocusLayout layout = (AdLocusLayout)adView;
| + | |
| − | }
| + | |
| − | | + | |
| − | @Override
| + | |
| − | public void onFailedToReceiveAd(Ad adView, AdLocusLayout$ErrorCode errorCode)
| + | |
| − | {
| + | |
| − | AdLocusLayout layout = (AdLocusLayout) adView;
| + | |
| − | switch (errorCode)
| + | |
| − | {
| + | |
| − | case NO_FILL:
| + | |
| − | //無廣告展示.
| + | |
| − | break;
| + | |
| − | case INVAILD_KEY:
| + | |
| − | //錯誤的APP KEY.
| + | |
| − | break;
| + | |
| − | case NETWORK_ERROR:
| + | |
| − | //網路連線問題
| + | |
| − | break;
| + | |
| − | case SERVICE_ERROR:
| + | |
| − | //伺服器忙碌或維護中
| + | |
| − | break;
| + | |
| − | default:
| + | |
| − | break;
| + | |
| − | }
| + | |
| − | }
| + | |
| − | });
| + | |
| − | </syntaxhighlight>
| + | |
| | | | |
| | == Promotion == | | == Promotion == |
| − | 適地性優惠通知服務是依據全區定向或特定地理位置定向提供與您的使用者最適合的主動式訊息。
| + | * [[Android_Promotion|詳細說明]] |
| | | | |
| − | 啟動優惠通知服務,請將相關程式碼加在整個程式的進入點(例如:Application 的 onCreate )
| + | == Interstitial == |
| | + | * [[Android_Interstitial|詳細說明]] |
| | | | |
| − | *如欲使用新型態優惠通知服務啟動方式請使用10.2步驟啟動 | + | == Video == |
| | + | * [[Android_Video|詳細說明]] |
| | | | |
| − | 10.新型態優惠通知服務
| + | == AdMob Mediation == |
| − | 10.1AndroidManifest.xml 的 Application 底下加入下列程式碼。
| + | * [[Android_AdMM|詳細說明]] |
| − | 背景Activity 需填入主畫面Activity,如:”.MainAcitvity” 或 “com.example.ExampleApp”
| + | |
| − | 10.2啟動優惠通知服務。
| + | |
| − | 背景Activity 需填入與10.1步驟相同的主畫面Activity,如:MainActivity.class
| + | |
| − | | + | |
| − | *與9.5請擇一使用
| + | |
| − | | + | |
| − | | + | |
| − | == 新型優惠通知服務 == | + | |
| − | | + | |
| − | 關閉優惠通知服務請使用下列程式碼
| + | |
| − | | + | |
| − | 9.6可加入按鈕讓使用者開啟個人化優惠通知的設定頁面
| + | |
| − | | + | |
| − | 9.7測試優惠通知服務是否成功整合
| + | |
| − | | + | |
| − | 如果整合成功將出現測試優惠通知,如下圖所示。
| + | |
| − | | + | |
| − | 如果未出現請重新檢查。
| + | |
| − | | + | |
| − |
| + | |
| − | == ProGuard ==
| + | |
| − | 您的專案若有透過 Proguard 進行混淆,請加入下列設定檔維持相容性。
| + | |
| − | | + | |
| − | <syntaxhighlight lang="java">
| + | |
| − | -keep public class com.adlocus.** {*;}
| + | |
| − | -keep class com.adlocus.adapters.AdLocusAdapter$MyJavaScriptInterface{<methods>;}
| + | |
| − | </syntaxhighlight>
| + | |
| | | | |
| | == 測試模式與觀眾定向(Optional) == | | == 測試模式與觀眾定向(Optional) == |
| Line 191: |
Line 54: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | == 開啟測試/定向 == | + | === 開啟測試/定向 === |
| | | | |
| − | === InApp === | + | ==== InApp ==== |
| | <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> |
| | AdLocusLayout adlocusLayout1 = new AdLocusLayout(this, | | AdLocusLayout adlocusLayout1 = new AdLocusLayout(this, |
| Line 202: |
Line 65: |
| | </syntaxhighlight> | | </syntaxhighlight> |
| | | | |
| − | === Promotion === | + | ==== Promotion ==== |
| | <syntaxhighlight lang="java"> | | <syntaxhighlight lang="java"> |
| − | AdLocusTargeting.enablePush(this, app key, targeting);
| + | PushAd.enablePush(this, "your app key", promotionIntent, targeting); |
| | </syntaxhighlight> | | </syntaxhighlight> |
以下將說明您怎麼整入 AdLocus SDK.
若您已完成上述檢查卻無法正確啟用相關服務, 請來信 support@adlocus.com , 我們將有專人與您聯繫.
當您完成 SDK 整合後,您可透過設定下列參數開啟測試模式(測試模式下的互動在平台上將不記錄).
// 設定使用者年齡 (也可使用 setBirthday())
void setAge(int age)
void setBirthDate(GregorianCalendar birthday))
void setGender(AdLocusTargeting$Gender gender)
void setTestMode(boolean isTesting)
// 設置範例:
AdLocusTargeting targeting = new AdLocusTargeting();
targeting.setAge(23);
targeting.setBirthDate(new GregorianCalendar(1990, 12, 29));
targeting.setGender(AdLocusTargeting$Gender.MALE);
targeting.setTestMode(true); //使用測試模式
AdLocusLayout adlocusLayout1 = new AdLocusLayout(this,
AdLocusLayout.AD_SIZE_IAB_MRECT,
appKey,
15,
targeting);
PushAd.enablePush(this, "your app key", promotionIntent, targeting);