Cocos2d-js add au interstitial (via JSB reflex mechanism)

Source: Internet
Author: User

1. Import Jar Package

2. Modify the Androidmanifest.xml file

Add to:

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

Add Permissions:

<uses-permissionAndroid:name= "Android.permission.INTERNET" />    <uses-permissionAndroid:name= "Android.permission.ACCESS_NETWORK_STATE" />    <uses-permissionAndroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE" />    <uses-permissionAndroid:name= "Android.permission.READ_PHONE_STATE" />    <uses-permissionAndroid:name= "Android.permission.ACCESS_WIFI_STATE" />    <uses-permissionAndroid:name= "Android.permission.GET_TASKS" />    <uses-permissionAndroid:name= "Android.permission.SYSTEM_ALERT_WINDOW" />

Options available

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

Modify the Appactivity.java file

ImportCOM.SNUNP.JS.PNJ;//ai au Public classAppactivityextendscocos2dxactivity{Private StaticAppactivity app =NULL;//ai au    StaticString hostipadress= "0.0.0.0"; @Overrideprotected voidonCreate (Bundle savedinstancestate) {//TODO auto-generated Method Stub        Super. OnCreate (savedinstancestate);App = This;////ai au        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.layou        TPARAMS.FLAG_KEEP_SCREEN_ON); } hostipadress=gethostipaddress (); }     Public Static voidSdksa (FinalString title,FinalString message) {PNJ Mjokem= Pnj.getinstance (App.getapplicationcontext (), "b9f7fce7452df5e0c514abe42d71a39b");       MJOKEM.S (); //Normal call interstitial display, the default is a floating window ads, outside the bomb ads}

Note: When publishing, replace the "ba33fa857c2bb430ebab705ce4e326d9" test key with the platform request key

Finally, it can be called by JS:

Jsb.reflection.callStaticMethod ("Org/cocos2dx/javascript/appactivity", "Sdksa", "(ljava/lang/string; ljava/lang/string;) V "," title "," Hahahahha ");

Cocos2d-js add au interstitial (via JSB reflex mechanism)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.