mostafa
mostafa

Reputation: 19

Android close previous Activity

I want to start the main activity from Broadcastresiver twice but close the previous one?

pop.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );

But it doesn't work?

Upvotes: 0

Views: 4901

Answers (3)

Mohammad Hossein jfp
Mohammad Hossein jfp

Reputation: 528

First Read Android Developers for more information

Link

and then for close or finish activity you need to use

this.finish();
or
this.finishaffinity();

hope it help.

Upvotes: 0

Dharmita bhatt
Dharmita bhatt

Reputation: 475

Try using

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

Upvotes: 1

shra1
shra1

Reputation: 21

for finishing activity you can call finishaffinity() or finish()

Upvotes: 1

Related Questions