My app is a message app and it have an activity that perform inbox functionality. So, in my inbox i will list unread messages on top and read messages at bottom.
So if i click on an unread message it will move to new activity which displays the particular message selected and in my database i will mark it as read. So, on clicking back, when it moves to the previous activity this message should be displayed among the read ones. But, in my case it is showing the old scenario i.e, the message is still displayed among unread.
I thought that the activity should be refreshed when it returns so i tried some refreshing methods like:
1.
public void onResume(Bundle s)
{ // After a pause OR at startup
super.onResume();
this.onCreate(s);
}
2.
Intent intent = new Intent(this, msgdisplayActivity.class); //msgdisplayActivity is activity which display the selected message.
//intent.putExtra("someData", "Here is some data");
startActivityForResult(intent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==RESULT_OK){
Intent refresh = new Intent(this, inboxlist.class); //inboxlist is activity which list the read and unread messages
startActivity(refresh);
this.finish();
}
}
But both of this didn't. onResume()
is not being called and the other one shows error.