Implementation for reward 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 rewarded video ad will be done with the following five steps.
First, generate the instance of NendAdRewardedVideo
.
Kotlin
import net.nend.android.NendAdRewardedVideo
...
class VideoActivity : AppCompatActivity() {
private lateinit var nendAdRewardedVideo: NendAdRewardedVideo
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
nendAdRewardedVideo = NendAdRewardedVideo(this, spotId, "apikey")
}
}
Java
import net.nend.android.NendAdRewardedVideo;
...
public class MainActivity extends AppCompatActivity {
NendAdRewardedVideo mNendAdRewardedVideo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mNendAdRewardedVideo = new NendAdRewardedVideo(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
nendAdRewardedVideo.loadAd()
Java
mNendAdRewardedVideo.loadAd();
You can get ad type information by type
property.
type | Description |
---|---|
NORMAL |
Reward video ads |
PLAYABLE |
User-controllable ads |
After confirming that loading of ad is completed by isLoaded
, show the ad using showAd
.
Kotlin
if (nendAdRewardedVideo.isLoaded) {
nendAdRewardedVideo.showAd(this)
}
Java
if (mNendAdRewardedVideo.isLoaded()) {
mNendAdRewardedVideo.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 NendAdRewardedVideo
again.
Kotlin
nendAdRewardedVideo.releaseAd() // release ad
Java
mNendAdRewardedVideo.releaseAd(); // release ad
Please implement the following option as necessary. To acquire rewarded information, please register the following Event Listener.
Register event listener of NendAdVideoActionListener
using setActionListener
.
NendAdVideo
is the parent class of NendAdInterstitialVideo
and NendAdRewardedVideo
. The argument nendAdVideo
in each NendAdRewardedActionListener
listener is an object of NendAdRewardedVideo
.
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.NendAdRewardItem
import net.nend.android.NendAdRewardedActionListener
import net.nend.android.NendAdVideo
...
nendAdRewardedVideo.setActionListener(object : NendAdRewardedActionListener {
override fun onRewarded(nendAdVideo: NendAdVideo, nendAdRewardItem: NendAdRewardItem) {
// Rewarded item was granted
Log.d(TAG, "currencyName :
${nendAdRewardItem.currencyName}") // Rewarded currency name
Log.d(TAG, "currencyAmount :
${nendAdRewardItem.currencyAmount}") // Rewarded currency amount
}
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 -> {
nendAdRewardedVideo.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.NendAdRewardItem;
import net.nend.android.NendAdRewardedActionListener;
import net.nend.android.NendAdVideo;
...
mNendAdRewardedVideo.setActionListener(new NendAdRewardedActionListener() {
@Override
public void onRewarded(NendAdVideo nendAdVideo, NendAdRewardItem rewardedItem) {
// Rewarded item was granted
Log.d(TAG, "currencyName:" +
rewardedItem.getCurrencyName()); // Rewarded currency name
Log.d(TAG, "currencyAmount:" +
rewardedItem.getCurrencyAmount()); // Rewarded currency amount
}
@Override
public void onLoaded(NendAdVideo nendAdVideo) {
// loading of ad is completed
switch (mNendAdRewardedVideo.getType()) {
case PLAYABLE:
Log.d(TAG, "Playable ad is not provide playing state listener");
break;
case NORMAL:
NendAdVideoPlayingState state = mNendAdRewardedVideo.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
}
});
Rewarded information that can be acquire using the method of NendAdRewardItem
from the argument rewardedItem
of public void onRewarded(NendAdVideo nendAdVideo, NendAdRewardItem rewardedItem)
of NendAdRewardedActionListener
is as follows.
Method | Type | Description |
---|---|---|
getCurrencyName | String | Rewarded currency name |
getCurrencyAmount | int | Rewarded currency amount |
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 |
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
nendAdRewardedVideo.setUserId("User Id")
Java
mNendAdRewardedVideo.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()
nendAdRewardedVideo.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()
nendAdRewardedVideo.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();
mNendAdRewardedVideo.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();
mNendAdRewardedVideo.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.
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 reward 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