# 7.插屏广告
# 介绍
本 SDK 为接入方提供个性化模板插屏广告,开发者不用自行对广告样式进行编辑和渲染
# (1) 使用
/**
* 加载并显示插屏广告
*
* @param activity Activity
* @param positionId 广告位ID
* @param listener 监听回调
*/
Ads.loadInterstitialAd(Activity activity, String positionId, final FNInterstitialListener listener);
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# (2) 回调
public interface FNInterstitialListener {
/**
* 加载成功
*/
void onLoadSuccess();
/**
* 加载失败
*
* @param msg 错误信息
* @param code 错误代码
*/
void onLoadError(String msg, int code);
/**
* 广告被点击
*/
void onAdClicked();
/**
* 广告显示
*/
void onAdShow();
/**
* 广告关闭
*/
void onAdClose();
/**
* 视频错误
*
* @param msg 错误信息
* @param code 错误代码
*/
void onVideoError(String msg, int code);
/**
* 广告播放完毕
*/
void onVideoComplete();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# (3) 预加载
如果您需要使用预加载,则调用预加载方法加载广告
/**
* 预加载插屏
*
* @param context 上下文
* @param positionId 广告位ID
* @param listener 监听回调
* @return 插屏广告对象(调用show显示广告)
*/
FNPreInterstitialAd preInterstitialAd = Ads.preloadInterstitialAd(context, positionId, listener);
//加载广告
preInterstitialAd.load();
// 等待广告加载成功后在合适的位置调用显示广告(确认广告加载成功再调用)
preInterstitialAd.show(activity);
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13