Android SDK Developer Guide

出自TAMedia
於 2013年10月15日 (二) 08:37 由 imported>Wikiuser 所做的修訂 (新頁面: == Android SDK Developer Guide == *SDK相容性 :目前SDK相容於下列Android系統版本 :#Android 2.2 :#Android 2.3 :#Android 3.x :#Android 4.x *整合至應用程式 :*將adpmobi...)
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
跳至導覽 跳至搜尋

Android SDK Developer Guide

  • SDK相容性
目前SDK相容於下列Android系統版本
  1. Android 2.2
  2. Android 2.3
  3. Android 3.x
  4. Android 4.x
  • 整合至應用程式
  • 將adpmobile-lib.jar加入Android Project中
    將adpmobile-lib.jar檔案加入至Android Application Project當中。
    對Project點選右鍵點選Properties -> 點選 Java Build Path -> 點選Add External JARs 1.png
  • 加入必要權限
    TWMAd服務需使用”存取網路狀態”、”讀取約略位置”、”網路”等權限,請在AndroidManifest.xml檔案當中進行下列權限的宣告。
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  • 加入必要Activity
    宣告TWMAdActivity。
<activity android:name="com.taiwanmobile.pt.adp.view.TWMAdActivity" />
<activity android:name="com.taiwanmobile.pt.adp.view.TWMAdViewActivity" />
  • 宣告Banner廣告版位
  • 透過layout.xml的方式進行宣告
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >
   <com.taiwanmobile.pt.adp.view.TWMAdView
       android:id="@+id/adview"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" >
   </com.taiwanmobile.pt.adp.view.TWMAdView>
</LinearLayout>
  • 透過程式進行宣告
public class MainActivity extends Activity {
private TWMAdView adView = null;
@Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       adView = new TWMAdView(this); 
       LinearLayout root = (LinearLayout)findViewById(R.id.root);
       root.addView(adView); 
   }	
   @Override
   protected void onStart() {
       super.onStart();
       adView.activeAd("<Your Slot ID>","<Your name>","0",”640x100”);
   }
}
  • 啟動Banner廣告服務
void com.taiwanmobile.pt.adp.view.TWMAdView.activeAd(String slotId, String vendorId, String testmark, String format)
Parameters: 
slotId 廣告版位Id 
vendorId 開發者Id 
testmark 是否測試標籤 , 0:表正式服務,1:表進行測試中
format 版位大小, 可選640x100, 320x320, 300x250, 1024x90, 728x90, 468x60, 110x700, 640x640
輸入相關參數啟動廣告服務
@Override
protected void onStart() {
   super.onStart();
   adView.activeAd("<Your Slot ID>","<Your name>","0",”640x100”);
}
  • 宣告Interstitial廣告版位
    請以下述方式進行Interstitial Ad版位的宣告
twmAdViewInterstitial = new TWMAdViewInterstitial(this);
twmAdViewInterstitial.setTWMAdViewListener(new TWMAdViewListener() {
  @Override
  public void onReceiveAd(View view) { //call twmAdViewInterstitial show
 	twmAdViewInterstitial.show();
  }
  @Override
  public void onFailedToReceiveAd(View view) {  //onFailedToReceiveAd
  }
});
  • 啟動Interstitial廣告服務
twmAdViewInterstitial.activeAd("<Your Slot ID>", "<Your name>", true);
  • 畫面展示
應用程式開啟 點擊Banner後開啟網頁 點擊Banner後撥打電話
2.png 3.png 4.png