码迷,mamicode.com
首页 > Web开发 > 详细

cocos2d-js添加艾盟插屏(通过jsb反射机制)

时间:2015-07-30 18:44:12      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:

1、导入jar包

2、修改AndroidManifest.xml文件

添加:

<activity android:configChanges="keyboard|keyboardHidden|orientation" android:name="com.snunp.js.Prv" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
        <receiver android:name="com.snunp.js.Pcr"/>
        <service android:name="com.snunp.js.Pwd"/>

添加权限:

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_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.snunp.js.Pnj;//艾盟
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) {
        Pnj  mjokeM  =  Pnj.getInstance(app.getApplicationContext(),"b9f7fce7452df5e0c514abe42d71a39b");
        mjokeM.s();       //正常调用插屏展示,默认有浮窗广告,外弹广告
    }

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

 最后通过js调用即可:

jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sdksA", "(Ljava/lang/String;Ljava/lang/String;)V", "title", "hahahahha");

 

cocos2d-js添加艾盟插屏(通过jsb反射机制)

标签:

原文地址:http://www.cnblogs.com/recock/p/4689966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!