AppActivity.java文件:
public static AppActivity activity = null;
在onCreate的函数中添加
activity = this;
ts调用java,如果涉及到UI,一定要在UI线程中执行,如果不涉及UI,也可以在UI线程中执行:
//不显示状态栏
public static void addFullScreen() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Window window = activity.getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
});
}
//显示状态栏
public static void clearFullScreen() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
new Handler().postDelayed(new Runnable(){
public void run() {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
});
}
}, 222);
}
});
}
java调用ts,一定要在GL线程中执行
activity.runOnGLThread(new Runnable() {
@Override
public void run() {
String js = "cc.NativeBridge.callPickPhoto(";
String params = "'"+nameParam+"'";
js = js + params + ");";
Cocos2dxJavascriptJavaBridge.evalString(js);
}
});