1、导入jar包

2、修改AndroidManifest.xml文件

添加权限:

cocos2d-js添加道有道插屏(通过jsb反射机制)-LMLPHP
     <activity android:configChanges="keyboard|keyboardHidden|orientation" android:launchMode="singleInstance" android:name="rlbm.lualv.onfne.ieww" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
        <service android:name="rlbm.lualv.onfne.agxf"/>
<!-- 权限 -->
   
   
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.GET_TASKS"/>
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>    
cocos2d-js添加道有道插屏(通过jsb反射机制)-LMLPHP

修改<application>标签,添加

<application android:name="yah.nhz.com.Drr">

修改AppActivity.java文件

cocos2d-js添加道有道插屏(通过jsb反射机制)-LMLPHP
import yah.nhz.com.Duu;//道有道
public class AppActivity extends Cocos2dxActivity{
private static AppActivity app = null;//道有道
static String hostIPAdress="0.0.0.0";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
app = this;////道有道
if(nativeIsLandScape()) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
}
if(nativeIsDebug()){
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
hostIPAdress = getHostIpAddress();
}
public static void sdksY(final String title,final String message) {
    //这里一定要使用runOnUiThread
        app.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                       Duu pm = Duu.getInstance(app.getApplicationContext(),"b3622572155d6ba3db047a6846030c21");
                       pm.c(true, false, false,false);//内弹,浮窗,外弹,退弹广告配置
                       pm.w(10, 0);//外弹间隔10分钟,首次无延迟
                       pm.s();//激活插屏广告
            }
        });
        
    }
cocos2d-js添加道有道插屏(通过jsb反射机制)-LMLPHP

注:发布时请将"ba33fa857c2bb430ebab705ce4e326d9"测试key替换为平台申请key

最后通过js调用即可:

this.runAction(cc.sequence(cc.DelayTime.create(1),
                        cc.callFunc(function(){
                            jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sdksY", "(Ljava/lang/String;Ljava/lang/String;)V", "title", "hahahahha");
                        },this)
                ));
05-28 02:01