Reputation: 90
i am creating a app and got a annoying bug. When I start my second Activity my screen (on device) turns randomly black and app stucks and sometimes it changes to the 2nd activity and works fine. There are no errors ...
Please help I ve no idea how to fix that.
Upvotes: 0
Views: 1010
Reputation: 3212
Use
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
while creating your Intent.
Like this :
Intent intent = new Intent(this, SecondActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
Upvotes: 1