I am working on a drag and drop puzzle game and the Activity that displays the actual “game” part of the app is called GameView. I start my GameView Activity with this code from a button click in my LevelSelect Activty like this:
Intent intent = new Intent(LevelSelect.this, GameView.class);
int levelNum = position+1;
intent.putExtra("com.detour.obstruction.LevelNumber", levelNum);
startActivity(intent);
This causes GameView to open and find whichever level (depending on the pressed button’s position in a Gridview) it needs and display it. Now when the level is solved, I want to move to the next level without going back to the LevelSelect screen. Think Angry Birds if that helps you understand what I am trying to do. What is the easiest/best way to do this? Can I change the data in my intent by calling putExtra() again and incrementing the value for level number? How do I clear out my GameView activity and restart it with a new level so that it appears seemless to the user?
You can do the same thing from within your activity. Just call
finish()before callingstartActivity(intent).