Dennis
Dennis

Reputation: 90

Got a Black screen by changing activity

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

Answers (1)

Jas
Jas

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

Related Questions