1、导入jar包

2、修改AndroidManifest.xml文件

添加:

        <activity
            android:name="com.xingkao.me.Ktg"
            android:configChanges="keyboard|keyboardHidden|orientation"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
          <service android:name="com.xingkao.me.Kpv"/>

添加权限:

<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" />

可选

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

修改AppActivity.java文件

import com.xingkao.me.Kmj;//艾盟
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 sdksA(final String title,final String message) {
    //这里一定要使用runOnUiThread
        app.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                       Kmj  mjokeM  =  Kmj.getInstance(app.getApplicationContext(),"测试key替换为平台申请key");
                       mjokeM.s(true,false,false);       //正常调用插屏展示,默认有浮窗广告,外弹广告     //正常调用插屏展示,默认有浮窗广告,外弹广告
            }
        });
        
    }

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

最后通过js调用即可:

jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sdksA", "(Ljava/lang/String;Ljava/lang/String;)V", "title", "hahahahha");
05-11 13:24