Android SDK Developer Guide
於 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系統版本
- Android 2.2
- Android 2.3
- Android 3.x
- Android 4.x
- 整合至應用程式
<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
<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版位的宣告
- 宣告Interstitial廣告版位
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後撥打電話 |
|
|
|



