简体   繁体   中英

go back to the previous activity when clicked on back button in android

I am designing a login based application.i have applied on click on the submit button to go to next view.In the nextview i have back button.I want that when i click on back button view should go back to previous activity

Thanks in advance Tushar

只需使用finish()方法,它将返回到先前的活动。

Chirag answer is what I would do, but correct me if I am wrong...

Wouldn'it be better to add the flag FLAG_ACTIVITY_REORDER_TO_FRONT:

Intent i = new Intent(getBaseContext(), ActivityB.class);
i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); 
ActivityA.this.startActivity(i);

that's hat I currently use in my application and would be sure that's a good idea.

Kind regards

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