-
Notifications
You must be signed in to change notification settings - Fork 7
Implementation for interstitial video ads
Please refer to the link below if you have not created ad spot or downloaded the SDK.
If you have not added the SDK to project, please add it with the following method.
Implementation of interstitial video ad will be done with the following five steps.
First, generate the instance of NendAdInterstitialVideo
.
Kotlin
import net.nend.android.NendAdInterstitialVideo
...
class VideoActivity : AppCompatActivity() {
private lateinit var nendAdInterstitialVideo: NendAdInterstitialVideo
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
nendAdInterstitialVideo = NendAdInterstitialVideo(this, spotId, "apikey")
}
}
Java
import net.nend.android.NendAdInterstitialVideo;
...
public class MainActivity extends AppCompatActivity {
NendAdInterstitialVideo mNendAdInterstitialVideo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mNendAdInterstitialVideo = new NendAdInterstitialVideo(this, spotId, "apikey");
}
}
Argument | Type | Description |
---|---|---|
context | Context | |
spotId | int | Unique spot id for your app given by nend console |
apiKey | String | Unique api key for your app given by nend console |
Load the ad using loadAd
.
Kotlin
nendAdInterstitialVideo.loadAd()
Java
mNendAdInterstitialVideo.loadAd();
You can get ad type information by type
property.
type | Description |
---|---|
NORMAL |
Interstitial video ads |
PLAYABLE |
User-controllable ads |
Kotlin
if (nendAdInterstitialVideo.isLoaded) {
nendAdInterstitialVideo.showAd(this)
}
Java
if (mNendAdInterstitialVideo.isLoaded()) {
mNendAdInterstitialVideo.showAd(this);
}
Please make sure to call the releaseAd
method if your video ad session has been completed or will not use video ad again on onDestroy
of Activity
.
Discard unnecessary resources for video ad with releaseAd
method. Also, if called during loading of ad will also cancel that load.
Also, if want to use video ad again after calling the releaseAd
method, create an instance of NendAdInterstitialVideo
again.
Kotlin
nendAdInterstitialVideo.releaseAd() // release ad
Java
mNendAdInterstitialVideo.releaseAd(); // release ad
Please implement the following option as necessary.
- Register Event Listener
- Set up User Name
- Set up Features of User
- Set mute state to play video
- Display Fullscreen Ads
Register event listener of NendAdVideoActionListener
using setActionListener
.
NendAdVideo
is the parent class of NendAdInterstitialVideo
and NendAdRewardedVideo
. The argument nendAdVideo
in each NendAdVideoActionListener
listener is an object of NendAdInterstitialVideo
.
Interactive ads (NendAdVideoType.PLAYABLE) cannot receive any event from NendAdVideoPlayingStateListener |
Normal Video ads (NendAdVideoType.NORMAL) can receive callbacks when the video ads were played or stopped or finished.
Interactive ads (NendAdVideoType.PLAYABLE) is not video but working on the WebView.
Because of that, Interactive ads can't receive callback when the video ads were played or stopped or finished.
Kotlin
import net.nend.android.NendAdVideoActionListener
import net.nend.android.NendAdVideo
...
nendAdInterstitialVideo.setActionListener(object : NendAdVideoActionListener {
override fun onLoaded(nendAdVideo: NendAdVideo) {
// loading of ad is completed
when (nendAdVideo.type) {
NendAdVideoType.PLAYABLE -> Log.d(TAG, "Playable ad is not provide playing state listener")
NendAdVideoType.NORMAL -> {
nendAdInterstitialVideo.playingState()?.let {
it.playingStateListener = object : NendAdVideoPlayingStateListener {
override fun onStarted(nendAdVideo: NendAdVideo) {
// video started
}
override fun onStopped(nendAdVideo: NendAdVideo) {
// video stopped
}
override fun onCompleted(nendAdVideo: NendAdVideo) {
// video completed playing to the end
}
}
}
}
else -> Log.d(TAG, nendAdVideo.type.toString())
}
}
override fun onFailedToLoad(nendAdVideo: NendAdVideo, errorCode: Int) {
// loading of ad is failed
Log.d(TAG, "errorCode: $errorCode")
}
override fun onFailedToPlay(nendAdVideo: NendAdVideo) {
// playing of ad content is failed
}
override fun onShown(nendAdVideo: NendAdVideo) {
// ad shown
}
override fun onClosed(nendAdVideo: NendAdVideo) {
// ad closed
}
override fun onAdClicked(nendAdVideo: NendAdVideo) {
// ad clicked
}
override fun onInformationClicked(nendAdVideo: NendAdVideo) {
// information button clicked
}
})
Java
import net.nend.android.NendAdVideoActionListener;
import net.nend.android.NendAdVideo;
...
mNendAdInterstitialVideo.setActionListener(new NendAdVideoActionListener() {
@Override
public void onLoaded(NendAdVideo nendAdVideo) {
// loading of ad is completed
switch (mNendAdInterstitialVideo.getType()) {
case PLAYABLE:
Log.d(TAG, "Playable ad is not provide playing state listener");
break;
case NORMAL:
NendAdVideoPlayingState state = mNendAdInterstitialVideo.playingState();
if (state != null) {
state.setPlayingStateListener(new NendAdVideoPlayingStateListener() {
@Override
public void onStarted(NendAdVideo nendAdVideo) {
// video started
}
@Override
public void onStopped(NendAdVideo nendAdVideo) {
// video stopped
}
@Override
public void onCompleted(NendAdVideo nendAdVideo) {
// video completed playing to the end
}
});
}
break;
default:
break;
}
}
@Override
public void onFailedToLoad(NendAdVideo nendAdVideo, int errorCode) {
// loading of ad is failed
Log.d(TAG, "errorCode:" + errorCode);
}
@Override
public void onFailedToPlay(NendAdVideo nendAdVideo) {
// playing of ad content is failed
}
@Override
public void onShown(NendAdVideo nendAdVideo) {
// ad shown
}
@Override
public void onClosed(NendAdVideo nendAdVideo) {
// ad closed
}
@Override
public void onAdClicked(NendAdVideo nendAdVideo) {
// ad clicked
}
@Override
public void onInformationClicked(NendAdVideo nendAdVideo) {
// information button clicked
}
});
The information of the argument errorCode
of public void onFailedToLoad(NendAdVideo nendAdVideo, int errorCode)
is as follows.
Code | Description |
---|---|
204 | No delivery ads |
400 | BAD request |
5XX | Server error |
600 | Error in SDK |
601 | Ad download failed |
602 | Fallback fullscreen ad failed |
603 | Invalid network |
This option is deprecated on nendSDK v10.0.0
or higher
When setting a user id that your app's original identifier, set the name with a character string using setUserId
method.
Kotlin
nendAdInterstitialVideo.setUserId("User Id")
Java
mNendAdInterstitialVideo.setUserId("User Id");
This option is deprecated on nendSDK v10.0.0
or higher
In the nendSDK version 4.0.3 or higher, targeting-ad option of video ad is available to using Features of User. Here are available options.
- Gender
- Birthday
- Age
- Others: could be customized from own your app.
Kotlin
import net.nend.android.NendAdUserFeature
...
//e.g. Only single feature
val feature = NendAdUserFeature.Builder()
.setBirthday(1985,1,1) // Birthday (e.g. Jan 1, 1985)
.build()
nendAdInterstitialVideo.setUserFeature(feature)
...
//e.g. Multiple features
val feature = NendAdUserFeature.Builder()
.setGender(NendAdUserFeature.Gender.MALE) // Gender
.setBirthday(1985, 1, 1) // Birthday (e.g. Jan 1, 1985)
.setAge(34) // age
.addCustomFeature("stringParameter", "test") // Others: customized parameters that formatted key-value type.
.addCustomFeature("booleanParameter", true)
.addCustomFeature("integerParameter", 100)
.addCustomFeature("doubleParameter", 123.45)
.build()
nendAdInterstitialVideo.setUserFeature(feature)
Java
import net.nend.android.NendAdUserFeature;
...
//e.g. Only single feature
NendAdUserFeature feature = new NendAdUserFeature.Builder()
.setBirthday(1985, 1, 1) // Birthday (e.g. Jan 1, 1985)
.build();
mNendAdInterstitialVideo.setUserFeature(feature);
...
//e.g. Multiple features
NendAdUserFeature feature = new NendAdUserFeature.Builder()
.setGender(NendAdUserFeature.Gender.MALE) // Gender
.setBirthday(1985, 1, 1) // Birthday (e.g. Jan 1, 1985)
.setAge(34) // age
.addCustomFeature("stringParameter", "test") // Others: customized parameters that formatted key-value type.
.addCustomFeature("booleanParameter", true)
.addCustomFeature("integerParameter", 100)
.addCustomFeature("doubleParameter", 123.45)
.build();
mNendAdInterstitialVideo.setUserFeature(feature);
Note:
- Birthday is high priority than age if set both parameters.
- You can only using
String
orint
ordouble
orbool
value at custom parameters. - If you want to set age group, please use custom parameters not age.
Set mute to play video using setMuteStartPlaying
method.
And default value is true
.
Kotlin
nendAdInterstitialVideo.setMuteStartPlaying(false)
Java
mNendAdInterstitialVideo.setMuteStartPlaying(false);
If you can not display interstitial video for reasons such as out of stock, you can display fullscreen ads instead. In order to use this function, you need to register ad space of fullscreen ads separately on the management screen.
Kotlin
nendAdInterstitialVideo.addFallbackFullboard(full board spot id, "full board api key")
Java
mNendAdInterstitialVideo.addFallbackFullboard(full board spot id, "full board api key");
Please use one of the following test modes for video ads.
- Use test apiKey and spotID
- Register GAID(Google Advertising ID) to nend console.
-
Enabled application logging.
-
Generate interstitial video ad, then GAID value will be printed in debug logs.
-
Register GAID value on nend console.
-
2023年9月1日より、SDK v6.0.0未満では動画広告の配信を停止いたします。新しいバージョンのご利用をご検討ください。
-
Google Play Consoleのデータセーフティに関して、nendSDKのデータ収集項目のページを追加しました。詳しくはこちらをご覧ください。
-
Android 13より、Google Advertising IDのアクセスのために権限の追加を強く推奨しています。詳しくはSDKの組み込み方法をご覧ください。
-
v9.0.0よりSDK内部の依存性及び位置情報機能の完全な削除を行いました。詳しくは更新履歴を御覧ください。
-
らくらくスマートフォンの
F-01L
にて、特定のOSバージョンでバナー広告利用時にアプリがクラッシュするという報告を一部のメディア様から頂いております。詳細はこちらをご確認ください。 -
Google Play Services r30 よりライブラリプロジェクトの提供がなくなり、今後はEclipseプロジェクトへのGoogle Play Servicesの導入が不可能となったため、nendSDKにおいてもEclispeでの導入・開発のサポートを終了させていただきました。
EclipseからAndroidStudioへの移行はこちらをご参照ください。 -
Googleのデベロッパーポリシーの更新に伴い、v3.1.0のSDKよりインタースティシャル広告のアプリ終了時表示機能を廃止させていただきました。
-
Effective September 1, 2023, we will stop serving video ads with SDK under v6.0.0. Please consider using a newer version.
-
For data safety section in Google Play Console, We added a page about data collection used on nendSDK. For details, please see here.
-
Since Android 13, we highly recommend add the permision to access Google Advertising ID. For details, please see About integrate the SDK.
-
In v9.0.0, a new dependency had been added to the sdk and all functions of collecting location data are completely deleted.
-
We have received reports from some media that a model of smartphone,
F-01L
crashes when using banner ads on a specific OS version. For details, please check here. -
nendSDK terminated the introduction and development support of Eclispe as Google Play Services (r30) no longer provides library project and impossible to install Google Play Services to the Eclispe project.
Please check the link below for how to transfer from Eclipse to AndroidStudio. -
With the update of Google Developer Policy, we terminated the function to show interstitial ads before the user closes the app from v3.1.0 SDK.
- バナー型広告
- アイコン型広告
- インタースティシャル広告
- ネイティブ広告
- フルボード広告
- 動画広告
- 動画ネイティブ広告
- Release Notes
- Preparation
- Supported Devices and IDE
- nendSDK Data Collection Items
- nendSDK Privacy Policy
- About Information Button
- Banner Ad
- Icon Ads
- Interstitial Ad
- Native Ad
- Fullscreen Ad
- Video Ad
- Native Video Ad