一、接入方式

类型 依赖
aar glide,okhttp(可根据需求分别打包)

二、公共请求参数

参数 描述 示例值
appid 应用ID 1001
posid 广告位ID 2001
secret 秘钥 ABCD(由平台分配)

三、权限(uses-permission)

Android版本 权限 申请方式
VERSION.SDK_INT < 23 READ_PHONE_STATE
WRITE_EXTERNAL_STORAGE
REQUEST_INSTALL_PACKAGES
ACCESS_DOWNLOAD_MANAGER
AndroidManifest中注明
VERSION.SDK_INT >= 23 READ_PHONE_STATE
WRITE_EXTERNAL_STORAGE
REQUEST_INSTALL_PACKAGES
ACCESS_DOWNLOAD_MANAGER
AndroidManifest中注明
并且需要动态申请

四、SDK对接方式

1、导入war文件
    api(name:"app-admob",ext:'aar')

2、初始化代码 (参考代码见:五)
    new RewardVideoAd(this, "应用ID", "广告位ID","秘钥", this);

3、请注意配置 AndroidManifest.xml (针对Android10)

            application
                android:requestLegacyExternalStorage="true"
                android:hardwareAccelerated="true"
                ......>
        
        	/application>
            

五、回调接口(implements IRewardVideoAdListener)


1、视频获取成功
    onAdSuccess()

2、视频获取失败
    onAdFailed(String msg)

3、点击视频
    onAdClick(long currentPosition)

4、播放视频开始
    onVideoPlayStart()

6、播放视频完成
    onVideoPlayComplete()

7、播放视频错误
    onVideoPlayError(String msg)

8、视频播放被关闭
    onVideoPlayClose(long currentPosition)

9、视频广告页打开
    onLandingPageOpen()

10、视频广告页关闭
    onLandingPageClose()

11、视频播放时点击广告(有效点击)
    onReward(HashMap info)

12、视频预加载完毕
    onAdPreSuccess()

六、参考代码


final RewardVideoAd mRVad = new RewardVideoAd(AdPlayActivity.this, "2001","3010","Ruby",new IRewardVideoAdListener() {
    @Override
    public void onAdSuccess() {
        Log.i("mobad","显示视频");
        if (mRVad.isReady()) {
            mRVad.showAd();
        }else {
            Toast.makeText(AdPlayActivity.this, "请稍后", Toast.LENGTH_LONG).show();
        }
    }
    @Override
    public void onAdFailed(String s) {
        Log.i("mobad","视频onAdFailed");
    }
    @Override
    public void onAdClick(long l) {
        Log.i("mobad","视频onAdClick.");
    }
    @Override
    public void onVideoPlayStart() {
        Log.i("mobad","视频onVideoPlayStart.");
    }
    @Override
    public void onVideoPlayComplete() {
        Log.i("mobad","视频onVideoPlayComplete.");
    }
    @Override
    public void onVideoPlayError(String s) {
        Log.i("mobad","视频onAdClick.");
    }
    @Override
    public void onVideoPlayClose(long l) {
        Log.i("mobad","视频onVideoPlayClose.");
    }
    @Override
    public void onAdPreSuccess() {
        Log.i("mobad","视频onAdPreSuccess.");
    }
    @Override
    public void onLandingPageOpen() {
        Log.i("mobad","视频onLandingPageOpen.");
    }
    @Override
    public void onLandingPageClose() {
        Log.i("mobad","视频onLandingPageClose.");
    }
    @Override
    public void onReward(HashMap hashMap) {
        Log.i("mobad","视频有效点击广告:");
        
    }
});

 

七、混淆排除方案

-keep public class com.mob68.ad.** { *; }
-dontwarn com.mob68.ad.**

# okhttp
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

# okio
-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keep class okio.**{*;}
-dontwarn okio.**