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");