I want to update the data on my android fragment when it's loaded on top of the stack or when the application is resumed or on some button click event. I tried using attach and detach method but its not working. I also tried onbackstackchangedlistener()
but no success. Any help would be appreciated.
Asked
Active
Viewed 4,363 times
1
-
show what you have done so far. – urfusion Oct 24 '15 at 14:03
2 Answers
0
As he answered here
The fragments onResume()
or onPause()
will be called only when the Activities onResume()
or onPause()
is called.
They are tightly coupled to the Activity
.
Read the Handling the Fragment Lifecycle section of this article.

Community
- 1
- 1

Shailendra Madda
- 20,649
- 15
- 100
- 138
0
If you are able to get the onResume working as Shylendra answers here is how one could handle it.
Just put this code inside
onResume()
Here is an example for when you want to update your listview when you return to your fragment.
@Override
public void onResume() {
super.onResume();
if (allowRefresh)
{
allowRefresh = false;
myListView = db.load_apps();
getFragmentManager().beginTransaction().detach(this).attach(this).commit();
}
}

C. Skjerdal
- 2,750
- 3
- 25
- 50