简体   繁体   中英

Launch another intent from AndEngine activity

I have two activities, MainMenuActivity and GameActivity, that each inherit from AndEngine's BaseGameActivity. I'm trying to launch the game from the main menu:

startActivity(new Intent(getApplication(), GameActivity.class));
finish();

This is being called from within onSceneTouchEvent. This causes the application to crash in PoolUpdateHandler::onUpdate, on the line that says "synchronized (scheduledPoolItems)".

I feel like this should be simple. Any clues?

Try the suggestion with swapping out getAppliction() with this . You want to pass in a reference to the current activity's context rather than passing in your application reference.

This works for my game:

startActivity(new Intent(this, GameActivity.class));
finish();

In which "this" is the andengine gameActivity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM