标签:
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");
标签:
原文地址:http://www.cnblogs.com/recock/p/4820219.html