M Jesse M Jesse - 6 months ago 31
Android Question

Android: Detect when an activity returns to the previous activity

I have activity A with a listView, a user clicks on any item which starts Activity B. Depending on what the user does in activity B may change the listView on activity A.

So my question:

How can I tell activity A that it was resumed when the user returns to it from activity B?

I want to be able to signal a refresh of the listView in activity A when it is returned to.

Thanks!

Answer

You can add the code to refresh listview in the onResume() of Activity A.

@Override
protected void onResume() {
    super.onResume();
    //Code to refresh listview
}