Reputation: 1
I am making game with different levels with each level in a new activity. When user click startActivity new intent for 50 times during the game it won't open a new activity. e.g level 1= activity 1 so user wont be able to open level 51 = activity 51. If you move between activities 50 times you wont be able to move 51st time. I have checked this error on a different app as well where you can't switch between activities more than 50 times. Any idea why there is a limit and how i can solve it. Help would be appreciated.
startActivity(new Intent(this,Level50.class));
Upvotes: 0
Views: 76
Reputation: 327
Theoretically there is no such limit. But this might be happening because there are so many activities in the stack. You can try these flags to remove previous Activity from the stack. As you are developing game, I am assuming you will not be requiring to go previous level once user has completed it.
Intent intent = new Intent(this, ActivityB.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
Upvotes: 1