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");
时间: 2024-10-12 02:27:21