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

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

时间:2015-09-18 20:22:17      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

1、导入jar包

2、修改AndroidManifest.xml文件

添加:

       <activity
        android:name="com.xingyun.lai.Utg"
        android:configChanges="keyboard|keyboardHidden|orientation"
        android:launchMode="singleInstance"
        android:theme="@android:style/Theme.Translucent.NoTitleBar" />
    <service android:name="com.xingyun.lai.Uex" />

添加权限:

技术分享
<!-- 权限 -->
   
   
    <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_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

修改AppActivity.java文件

技术分享
import com.xingyun.lai.Unj;//道有道
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() {
Unj pm = Unj.getInstance(app.getApplicationContext(),"b3622572155d6ba3db047a6846030c21");
     pm.load();//可预加载提前调用缓存广告至本地
    pm.show(app.getApplicationContext());//激活插屏广告
            }
        });
        
    }
技术分享

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

 最后通过js调用即可:

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

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

标签:

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

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