Incentiveized Video Integration Guide(Eclipse) - united-adstir/AdStir-Integration-Guide-Android GitHub Wiki

Caution

You'll need to replace all SDKs included in the package when you update a SDK. If you use different versions of SDKs, the system may not operate properly.

Currently, the affilieted network "Vungle" has suspended providing bundled SDK for some reasons. If you update a SDK from old version to latest version, please delete Vungle SDK and its adaptor before you use it.

vungle-publisher-adaptive-id-3.3.5.jar
dagger-2.1.jar
javax.inject-1.jar
androidwebviewmediation-videoreward-vungle.jar

Along with this, the system may get exceptions as below. However, it won't effect on operation, so please keep using it.

java.lang.ClassNotFoundException: com.ad_stir.interstitial.mediationadapter.Vungle

We are sorry for the inconvenience.

Supported OS version

Android 4.1 or later

SDK download

Get SDK from "Get SDK/Code" page on AdStir site.

SDK parameter

Get SDK parameter from "Get SDK/Code" page on AdStir site.

Project Settings

Set Compile SDK Version API18 or later.

Add library

Put adstirwebview.jar, androidwebviewmediation-*.jar, and bundled all sdks to your project's libs folder. But the bundled Library project must be imported, and add to your project's Property->Android->Library.

Setup Google Play services

AdStir SDK requires Google Play services.
Please setup the library.

AndroidManifest.xmlへの記述

** This section will be changed on SDK update. Don't forget checking. **

Add permissions.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

In element, please add following lines.

<activity android:name="com.jirbo.adcolony.AdColonyOverlay"
	android:configChanges="keyboardHidden|orientation|screenSize"
	android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyFullscreen"
	android:configChanges="keyboardHidden|orientation|screenSize"
	android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyBrowser"
	android:configChanges="keyboardHidden|orientation|screenSize"
	android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />

<activity android:name="com.inmobi.androidsdk.IMBrowserActivity"
        android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:hardwareAccelerated="true" />

<activity android:name="com.applovin.adview.AppLovinInterstitialActivity" />
<activity android:name="com.applovin.adview.AppLovinConfirmationActivity" />

<activity android:name="com.ad_stir.videoincentive.AdstirFullscreenActivity"
	android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
	android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />

<activity
    android:name="jp.maio.sdk.android.AdFullscreenActivity"
    android:label="maiosdk"
    android:configChanges="orientation|screenLayout|screenSize|smallestScreenSize"
    android:hardwareAccelerated="true"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
    <intent-filter>
        <data android:scheme="jp.maio.sdk.android"/>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

<activity
    android:name="com.vungle.publisher.FullScreenAdActivity"
    android:configChanges="keyboardHidden|orientation|screenSize"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>

ProGuard Configuration

If you use ProGuard, please configure following settings.

# adstir
-dontwarn com.ad_stir.**
-keep class com.ad_stir.** { *; }
-keep interface com.ad_stir.** { *; }

# google
-keep class com.google.android.gms.ads.** {*;}

# adcolony
-dontwarn com.jirbo.adcolony.**
-keep class com.jirbo.adcolony.**{*;}

# inmobi
-keep class com.inmobi.** { *; }
-dontwarn com.inmobi.**

# applovin
-dontwarn com.applovin.**
-keep class com.applovin.**.*

# unity-ads
-keepattributes SourceFile,LineNumberTable
-keepattributes JavascriptInterface
-keep class android.webkit.JavascriptInterface {
   *;
}
-keep class com.unity3d.ads.** {
   *;
}

# maio
-dontwarn jp.maio.**
-keep class jp.maio.** { *; }
-keep interface jp.maio.** { *; }

# vungle
-keep class com.vungle.** { public *; }
-keep class javax.inject.*
-keepattributes *Annotation*
-keepattributes Signature
-keep class dagger.*

-keepattributes EnclosingMethod

Integration

// import required classes
import com.ad_stir.videoreward.AdstirVideoReward;
import com.ad_stir.videoreward.AdstirVideoRewardListener;

private boolean isRewarded = false;

// Define listner
private AdstirVideoRewardListener listener = new AdstirVideoRewardListener() {
	public void onLoad(int spot_no) {};
	public void onFailed(int spot_no) {};
	public void onStart(int spot_no) {};
	public void onStartFailed(int spot_no) {};
	public void onFinished(int spot_no) {};
	public void onReward(int spot_no) {
		isRewarded = true;
	};
	public void onRewardCanceled(int spot_no) {};
	public void onClose(int spot_no) {};
};


@Override
// Load Ad
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.xxxx);

	// Set user identifier for Server-Side Callback
	// You have to specify user identifier that your API identify the user.
	// AdstirVideoReward.setMediaUserID("XXXXXXXXXXX"); 

	// Initialize spots using this activity.
	int[] spotIds = { 1, 2 };
	AdstirVideoReward.init(this, "MEDIA-xxxxxx", spotIds);
	// Create instance per spot ID.
	adstirVideoReward = new AdstirVideoReward(this, "MEDIA-xxxxxx", 1);
	// Add listener defined before.
	adstirVideoReward.setAdstirVideoRewardListener(listener);
	// Start loading...
	adstirVideoReward.load();	
}

// Resume and Pause, Destroy
@Override
protected void onResume() {
	if(adstirVideoReward != null) adstirVideoReward.resume();
	if(isRewarded) {
		isRewarded = false;
		Log.d(TAG, "Reward success.");
	}
	super.onResume();
}

@Override
protected void onPause() {
	if(adstirVideoReward != null) adstirVideoReward.pause();
	super.onPause();
}

@Override
protected void onDestroy() {
	if(adstirVideoReward != null) adstirVideoReward.destroy();
	super.onDestroy();
}

Library Details

public class AdstirVideoReward

public static void init(Activity activity, String mediaId, int[] spotNoArray)

Global initialize method. Please call this before creating AdstirVideoReward instance.
You have to specify all spot numbers you use in app.

  • activity : Activity
  • mediaId : Medium ID
  • spotNoArray : Spot numbers

public static void setMediaUserID(String userId)

Set user identifier for Server-Side Callback

  • userId : Unique user identifier.

public AdstirVideoReward(Activity activity, String mediaId, int spotNo)

Constructor.

  • activity : Activity
  • mediaId : Medium ID
  • spotNo : Spot number

public void setAdstirVideoRewardListener(AdstirVideoRewardListener listener)

Set listener.

  • listener : Instance that implementing AdstirVideoRewardListner interface

public void setAppVersion(String appVersion)

Set application version.

  • appVersion : Application version string

public void setLocation(Location location)

Set user location for location-based targeting.

  • location : Instance of Location.

public void load()

Start loading Ad.

public void showRewardVideo()

Show Ad.

public void pause()

Pause the process. Call in onPause of activity.

public void resume()

Resume the process. Call in onResume of activity.

public void destroy()

Destroy instance. Call in onDestroy of activity.

public interface AdstirVideoRewardListener

Listener interface.

public void onLoad(int spot_no)

Notify an Ad was loded.

public void onFailed(int spot_no)

Notify failed loading Ad.

public void onStart(int spot_no)

Notify video was started.

public void onFinished(int spot_no)

Notify video was finished.

public void onReward(int spot_no)

Notify reward was verified.

public void onRewardCanceled(int spot_no)

Notify reward was cancelled.

public void onClose(int spot_no)

Notify video was closed.

Server-Side Callback

AdStir supports Server-Side Callback of incentive.

Callback API URL

Parameters

(*) required

Placeholder Value
${TRANSACTION_ID} (*) AdStir Reward Transaction Identifier
${USER_ID} (*) Media User ID that set before initialization
${CURRENCY} Incentive Currency
${AMOUNT} Incentive Amount
${IFA} Apple IDFA/Google Play Advertising ID

e.g.) http(s)://aaa.com/bbb?ccc=${TRANSACTION_ID}&ddd=${USER_ID}&eee=${CURRENCY}&fff=${AMOUNT}

Return 200 OK, when API received callback successfully.

IMPORTANT

  • Callback requests might duplicate. So you have to process it uniquely by ${TRANSACTION_ID}.
  • ${IFA} might be empty. You have to identify user by ${USER_ID}.
  • Callback timeout is set to 60sec.

Support

AdStir Contact Form

⚠️ **GitHub.com Fallback** ⚠️