//快手开屏页广告
public void showKuaishouAd() {
KsScene scene =new KsScene.Builder(addid)
//是否需要开屏小窗展示,默认为false, 设置false后将不会回调onShowMiniWindow
.needShowMiniWindow(true)
.build(); // 此为测试posId,请联系快手平台申请正式posId
KsAdSDK.getLoadManager().loadSplashScreenAd(scene, new KsLoadManager.SplashScreenAdListener() {
@Override
public void onError(int code, String msg) {
showTips("开屏广告请求失败" + code + msg);
}
@Override
public void onRequestResult(int adNumber) {
showTips("开屏广告广告填充个数:" + adNumber);
}
@Override
public void onSplashScreenAdLoad(@NonNull KsSplashScreenAd splashScreenAd) {
SplashAd.ksSplashScreenAd = splashScreenAd;
showTips("开始数据返回成功");
addView(splashScreenAd);
}
});
}
private void addView(final KsSplashScreenAd splashScreenAd) {
View view =
splashScreenAd.getView(this,
new KsSplashScreenAd.SplashScreenAdInteractionListener() {
@Override
public void onAdClicked() {
// showTips("开屏广告点击");
//onAdClick 会吊起h5或者应用商店。 不直接跳转,等返回后再跳转。
mGotoMainActivity =true;
//点击不出发显示miniWindow
SplashAd.ksSplashScreenAd =null;
}
@Override
public void onAdShowError(int code, String extra) {
// showTips("开屏广告显示错误" + code + " extra " + extra);
//出错不出发显示miniWindow
SplashAd.ksSplashScreenAd =null;
toMainActivity();
}
@Override
public void onAdShowEnd() {
// showTips("开屏广告显示结束");
toMainActivity();
}
@Override
public void onAdShowStart() {
// showTips("开屏广告显示开始");
// mEmptyView.setVisibility(View.GONE);
}
@Override
public void onSkippedAd() {
// showTips("用户跳过开屏广告");
toMainActivity();
}
});
if (!isFinishing()) {
ViewGroup root = findViewById(R.id.express_container);
root.removeAllViews();
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
root.addView(view);
}
}
import com.kwad.sdk.api.KsSplashScreenAd;
public class SplashAd {
public static KsSplashScreenAdksSplashScreenAd;
}
网友评论