Ad Exchange アプリ内広告の導入 - united-adstir/AdStir-Integration-Guide-Android GitHub Wiki
adstir SDK 2.14.6以上をご利用する場合はAndroidXへの移行が必要です。こちらを参考にAndroidXへ移行をお願いいたします。
Android 4.4 以降 adstir SDK 2.12.0よりadstirの広告はAndroid 4.4以上の端末にのみ配信されます。
- 320x50
- 320x100
- 300x250
対応提携ネットワークについてはこちらをご覧ください。
初期設定をご覧になり、adstir SDKをプロジェクトへ導入してください。 対応提携ネットワークを導入する場合はこちらを参考に対応提携ネットワークを導入してください。
実装方法の詳細についてはこちらを参照してください。
- activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.ad_stir.dfpimpltest.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<!-- ここでは、320x50サイズのバナー広告を表示します。 -->
<!-- サイズについての詳細は、営業担当者からお知らせ致します。 -->
<com.google.android.gms.ads.doubleclick.PublisherAdView
android:id="@+id/publisherAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.doubleclick.PublisherAdView>
</RelativeLayout>
- string.xml
<resources>
<string name="app_name">DFPimpltest</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<!-- 実際に配信に使用するAd Unit IDは、営業担当者から別途お知らせ致します。-->
<!-- こちらはテスト用のIDになります。-->
<string name="banner_ad_unit_id">/34264398/united_adstir_sample_android_87407/banner</string>
</resources>
- MainActivity.java
package com.ad_stir.dfpimpltest;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
import com.google.android.gms.ads.doubleclick.PublisherAdView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
com.amazon.device.ads.AdRegistration.enableTesting(true);
com.amazon.device.ads.AdRegistration.enableLogging(true);
PublisherAdView mPublisherAdView = (PublisherAdView) findViewById(R.id.publisherAdView);
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
mPublisherAdView.loadAd(adRequest);
}
}
FAQをご覧ください。