老铁们,安卓java里回掉js的方法不能用了吗,Cocos2dxJavascriptJavaBridge.evalString("");这句话放哪app都闪退,是我姿势错了吗?
public class AppActivity extends Cocos2dxActivity {
private static AppActivity app = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Workaround in
// https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
if (!isTaskRoot()) {
// Android launched another instance of the root activity into an existing task
// so just quietly finish and go away, dropping the user back into the activity
// at the top of the stack (ie: the last state of this task)
// Don't need to finish it again since it's finished in super.onCreate .
return;
}
app = this;
// DO OTHER INITIALIZATION BELOW
SDKWrapper.getInstance().init(this);
TimerTask task = new TimerTask() {
public void run() {
Log.d("cn.test", "@@@@@@@@@@@@@ test #############################");
Cocos2dxJavascriptJavaBridge.evalString("cc.log('@@@@@@@@@@@@@ test #############################')");
//callString("cc.log('@@@@@@@@@@@@@ test #############################')");
}
};
Timer timer = new Timer();
timer.schedule(task, 1000, 2000);
}
public static void callString(final String str){
app.runOnUiThread(new Runnable() {
@Override
public void run() {
Cocos2dxJavascriptJavaBridge.evalString(str);
}
});
}
}
creator 版本 2.1.3rc7,新建工程,发布default版,未做任何改动,只改动了AppActivity里的上面一点。