Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to use OnCreate() when pressing backbutton

When pressing the backbutton I want that, whatever screen will be loading, the onCreate() method will be executed. I want this because the screens must be refreshing when navigating through the app.

Do I need to override the back button method?

if(keyCode == KeyEvent.KEYCODE_BACK)
{

    }
like image 894
user1264255 Avatar asked Aug 30 '26 21:08

user1264255


1 Answers

When you press the back button, the onResume() method is called, so instead of using onCreate(), use this and do whatever you need to do for refreshing the activity.

like image 139
Finuka Avatar answered Sep 02 '26 12:09

Finuka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!