Payal
Payal

Reputation: 33

How can I close my app in background when click on button in android

I am showing a message on a button click ("plz verify Email."). And when the user click on the button then browser will be open and I want to redirect my app into first activity in background.

I want my app to return to his first state when the user come back on it.

Upvotes: 3

Views: 112

Answers (3)

Sparky
Sparky

Reputation: 8477

When the user clicks the button to close the dialog, then from the calling activity create an Intent and start the Browser with startActivityForResult().

In the same activity, implement onActivityResult(). In there, create an Intent and start your initial activity with startActivity().

For more information, refer to the Android docs on Activities and Intents.

Upvotes: 1

Shreyash Mahajan
Shreyash Mahajan

Reputation: 23596

Just call finish(); whenever you want to finish the Activity.

Upvotes: 0

Changwei Yao
Changwei Yao

Reputation: 13101

you can set a flag when you start the intent, and test it in onResume

when it was true, finish it self and start the first acrivity. Buy the way, set the launchMode of the first activity to singleTop

Upvotes: 0

Related Questions