zoukankan      html  css  js  c++  java
  • cocos2d-js添加360广告联盟插屏(通过jsb反射机制)

    1、添加demo里的libs里的jar包

    2、修改AndroidManifest.xml文件

    添加权限:

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

    添加声明:

    <service android:enabled="true" android:exported="false" android:name="com.qhad.ads.sdk.service.QhAdService"/>
    <activity android:configChanges="orientation|screenSize|keyboardHidden" android:name="com.qhad.ads.sdk.adcore.QhAdActivity"/>

    3、修改AppActivity.java文件

    import com.qhad.ads.sdk.adcore.Qhad;//360联盟
    import com.qhad.ads.sdk.interfaces.IQhAdEventListener;//360联盟
    import com.qhad.ads.sdk.interfaces.IQhInterstitialAd;//360联盟
    
    
    public class AppActivity extends Cocos2dxActivity{
        private static AppActivity app = null;//360联盟
        private static IQhInterstitialAd interstitialAd = null;//360联盟
        static String hostIPAdress="0.0.0.0";
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            app = this;//360联盟
            interstitialAd = Qhad.showInterstitial(app, "uP56FT6rAx", false);
            interstitialAd.setAdEventListener(new IQhAdEventListener() {
                @Override
                public void onAdviewIntoLandpage() {
                }
                @Override
                public void onAdviewGotAdSucceed() {
                }
                @Override
                public void onAdviewGotAdFail() {
                }
                @Override
                public void onAdviewRendered() {
                }
                @Override
                public void onAdviewDismissedLandpage() {
                }
                @Override
                public void onAdviewDestroyed() {
                }
                @Override
                public void onAdviewClosed() {   
                }
                @Override
                public void onAdviewClicked() { 
                }
            });
            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 sdks360(final String title,final String message) {
        //这里一定要使用runOnUiThread
            app.runOnUiThread(new Runnable() {
                @Override
               public void run() {
                          interstitialAd.showAds(app);
                }
            });
            
        }

    4、

     最后通过js调用即可:

    jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "sdks360", "(Ljava/lang/String;Ljava/lang/String;)V", "title", "hahahahha");
  • 相关阅读:
    MyBatis常见面试题以及解读
    如何防止sql注入攻击
    宝塔Linux面板基础命令
    Centos7配置静态ip
    宝塔Linux面板安装
    idea中安装阿里巴巴的代码规范插件
    idea中快速将类中的属性转为Json字符串的插件
    创建线程的四种方式
    sleep()方法与wait()方法的区别
    解决线程安全的几种方式
  • 原文地址:https://www.cnblogs.com/recock/p/5014538.html
Copyright © 2011-2022 走看看