简体   繁体   中英

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.

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 .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM