I have an activity A which has a feed kind of interface. There is a text on each of these feed items which indicate the number of comments on that item. Now if on that item, I click comment and go to new activity B, add comment through activity B and press back to go back to activity A. When I add the comment, the info is reflected in the backend. But the problem is, when I press back, the saved instance of activity A shows in which the number of comments is not updated because there is no call to backend from activity A.
What is the standard way of doing something like this? How should I refresh the previous screen in activity stack on pressing back on some activity?
Here are some relevant code snippets:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.gallery_page_button_back);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if(id == android.R.id.home) {
this.finish();
return true;
}
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}